cleankill

Hook SIGINT and cleanly shut down your async code

BSD-3-Clause 5 个版本
安装
npm install cleankill
yarn add cleankill
pnpm add cleankill
bun add cleankill
README

Cleankill

CleanKill hooks the interrupt handler, and provides callbacks for your code to cleanly shut down before the process exits.

As an escape hatch, if the user mashes interrupt, the process will be immediately killed.

Using It

var cleankill = require('cleankill');

To register a handler:

cleankill.onInterrupt(() => {
  return new Promise((resolve) => {
    // do things.
    resolve();
  });
});

If you wish to shut down any existing handlers (without exiting the process):

cleankill.close().then(() => {
  // All handlers have cleaned things up.
});
版本列表
2.0.0 2016-06-30
1.0.3 2016-06-28
1.0.2 2015-04-08
1.0.1 2015-04-02
1.0.0 2015-01-16