lib/loader.js
async function authenticate(database) {
    database[AUTH_RETRIES] = database[AUTH_RETRIES] || 0;

    try {
      await database.authenticate();
    } catch (e) {
      if (e.name !== 'SequelizeConnectionRefusedError') throw e;
      if (app.model[AUTH_RETRIES] >= 3) throw e;

      // sleep 2s to retry, max 3 times
      database[AUTH_RETRIES] += 1;
      app.logger.warn(`Sequelize Error: ${e.message}, sleep 2 seconds to retry...`);
      await sleep(2000);
      await authenticate(database);
    }
  }
async function authenticate(database) {
    database[AUTH_RETRIES] = database[AUTH_RETRIES] || 0;

    try {
      await database.authenticate();
    } catch (e) {
      if (e.name !== 'SequelizeConnectionRefusedError') throw e;
      if (app.model[AUTH_RETRIES] >= 3) throw e;

      // sleep 2s to retry, max 3 times
      database[AUTH_RETRIES] += 1;
      app.logger.warn(`Sequelize Error: ${e.message}, sleep 2 seconds to retry...`);
      await sleep(2000);
      await authenticate(database);
    }
  }
async function authenticate ( database ) { database [ AUTH_RETRIES ] = database [ AUTH_RETRIES ] || 0 ; try { await database . authenticate ( ) ; } catch ( e ) { if ( e . name !== 'SequelizeConnectionRefusedError' ) throw e ; if ( app . model [ AUTH_RETRIES ] >= 3 ) throw e ; // sleep 2s to retry, max 3 times database [ AUTH_RETRIES ] += 1 ; app . logger . warn ( ` ${ e . message } ` ) ; await sleep ( 2000 ) ; await authenticate ( database ) ; } }
Authenticate to test Database connection.

This method will retry 3 times when database connect fail in temporary, to avoid Egg start failed.
@param {Application} database instance of sequelize
Authenticate to test Database connection .