How to use the async-exit-hook.uncaughtExceptionHandler 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 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 {

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