nator

0.0.2 • Public • Published
   _  _____ __________  ___ 
  / |/ / _ /_  __/ __ \/ _ \
 /    / __ |/ / / /_/ / , _/
/_/|_/_/ |_/_/  \____/_/|_| 

(Assasi)nator

The graceful shutdown handler for loop-based operating NodeJS apps.

Say what? E.g. a shutdown handler for apps that have a sequential execution flow loop (treadmill-like) as for example:

var doSomething = function() {
    // do something here
    doSomethingAgain();
}
var doSomethingAgain = function() {
    doSomething(); // again!
}
 
doSomething();

Usage

Given that your app is running on a treadmill (like the example above), all you need to do to handle graceful shutdowns (such that the last running loop will always finish up), is the following:

var Nator = require('nator');
 
var doSomething = function() {
    // do something here
    doSomethingAgain();
}
var doSomethingAgain = function() {
    doSomething(); // again!
}
 
var nator = new Nator.handler(doSomething);
 
nator.start();

Optionally, you may pass a custom shutdown function to the .start() that will execute upon receiving SIGINT, SIGHUP or SIGTERM signals. You will need to issue process.exit() on your own inside the shutdown function when doing so.

Licence

MIT.

Readme

Keywords

none

Package Sidebar

Install

npm i nator

Weekly Downloads

2

Version

0.0.2

License

none

Last publish

Collaborators

  • pipedrive-inc