0.0.4 • Published 5 years ago

@redneckz/node-terminator v0.0.4

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

node-terminator

Handle NodeJS termination (SIGTERM/SIGINT) gracefully.

NPM Version Build Status Coverage Status

Installation

npm install --save @redneckz/node-terminator

How-to

Create NodeTerminator instance and attach it to NodeJS process (several instances can be created and attached).

const { NodeTerminator } = require('@redneckz/node-terminator');

const nodeTerminator = new NodeTerminator();
nodeTerminator.attach(() => {
  // Some additional steps before exit
  process.exit();
});

Decorate async jobs to control gracefull shutdown.

const {
  graceful, // HOF bound to NodeTerminator instance
} = nodeTerminator;

const someJob = graceful(async () => {
  // Do something asynchronously
  console.log('Working hard...');
});

License

MIT