How to use async-exit-hook - 8 common examples

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 DevExpress / testcafe / src / utils / temp-directory / index.js View on Github external
async dispose () {
        if (!USED_TEMP_DIRS[this.path])
            return;

        this.lockFile.dispose();

        await cleanupProcess.removeDirectory(this.path);

        delete USED_TEMP_DIRS[this.path];
    }
}

// NOTE: exposed for testing purposes
TempDirectory.TEMP_DIRECTORIES_ROOT = TESTCAFE_TMP_DIRS_ROOT;

setupExitHook(TempDirectory.disposeDirectoriesSync);
github davidmerfield / Blot / app / build / index.js View on Github external
var debug = require("debug")("blot:build");
var helper = require("helper");
var clfdate = helper.clfdate;
var workers = [];
var jobs = {};

debug("Master", process.pid, "is running");

exitHook(function() {
  debug("Shutting down master:", process.pid);
  workers.forEach(function(item) {
    item.worker.kill();
  });
});

exitHook.uncaughtExceptionHandler(function(err) {
  console.error(err);
  workers.forEach(function(item) {
    item.worker.kill();
  });
});

function messageHandler(id) {
  return function(message) {
    debug("Handling message", id);
    var err = null;

    // Ressurrect error from string. You can remove
    // this when we can pass something with type Error
    // between child processes in future.
    if (message.err) {
      try {
github RiseVision / rise-node / src / app.ts View on Github external
* Returns cleanup function
 */
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 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
* Takes care of bootstrapping the application
 * 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));
  });
github atomist / automation-client / lib / internal / util / shutdown.ts View on Github external
export function setForceExitTimeout(ms: number): void {
    exitHook.forceExitTimeout(ms);
}
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

70 / 100
Full package analysis