Async-exit-hook

async-exit-hook

Run some code when the process exits.

async-exit-hook is a fork from exit-hook which can catch:

  • process SIGINT, SIGTERM and SIGHUP, SIGBREAK signals
  • process beforeExit and exit events
  • PM2's exit.

As process.on('exit') event doesn't catch all the ways a process can exit.

Get it: npm install async-exit-hook

Sample usage:

1
2
3
4
5
6
7
8
9
10
exitHook(() => {
    console.log('exiting');
});

exitHook(callback => {
    setTimeout(() => {
        console.log('exiting');
        callback();
    }, 1000);
});

GIF FTW

async-exit-hook

Suggest a module

Comments