@redneckz/node-terminator

0.0.4 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @redneckz/node-terminator

Weekly Downloads

1

Version

0.0.4

License

MIT

Unpacked Size

10.2 kB

Total Files

9

Last publish

Collaborators

  • redneckz