How to use the async-exit-hook.unhandledRejectionHandler function in async-exit-hook

To help you get started, we’ve selected a few async-exit-hook examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github runnerty / runnerty / lib / app.js View on Github external
logger.log(
      'warn',
      `--> Failed to report unexpected closure to runnerty.io. ${err}`
    );
  }
}

process.on('uncaughtException', err => {
  if (err.code === 'EADDRINUSE') {
    logger.log('error', `Unable to start server: ${err.message}`);
  } else {
    logger.log('error', err.message);
  }
});

exitHook.unhandledRejectionHandler(err => {
  logger.log('error', err);
});

exitHook(callback => {
  preExit().then(_ => {
    callback();
  });
});
github RiseVision / rise-node / src / app.ts View on Github external
*/
async function boot(constants: typeof constantsType): Promise {
  const manager = new AppManager(
    appConfig,
    logger,
    versionBuild,
    genesisBlock,
    constants,
    allExceptionCreator
  );
  await manager.boot();
  return manager;
}

exitHook.forceExitTimeout(15000);
exitHook.unhandledRejectionHandler((err) => {
  logger.fatal('Unhandled Promise rejection', err);
});

boot(constantsType)
  .catch((err) => {
    logger.fatal('Error when instantiating');
    logger.fatal(err);
    process.exit(1);
    return Promise.reject(err);
  })
  .then((manager) => {
    exitHook((cb) => promiseToCB(manager.tearDown(), cb));
  });
github RiseVision / rise-node / packages / core-launchpad / src / app.ts View on Github external
* Returns cleanup function
 */
async function boot(): Promise {
  const manager = new AppManager(
    appConfig,
    logger,
    callingPackageJSON.version,
    genesisBlock,
    modules
  );
  await manager.boot();
  return manager;
}

exitHook.forceExitTimeout(15000);
exitHook.unhandledRejectionHandler((err) => {
  logger.fatal('Unhandled Promise rejection', err);
});

boot()
  .catch((err) => {
    logger.fatal('Error when instantiating');
    logger.fatal(err);
    return Promise.reject(err);
  })
  .then((manager) => {
    exitHook((cb) => promiseToCB(manager.tearDown(), cb));
  });

async-exit-hook

Run some code when the process exits (supports async hooks and pm2 clustering)

MIT
Latest version published 7 years ago

Package Health Score

67 / 100
Full package analysis