adding salt before node process exit
Node.js version >= 7.0.*
npm i --save signaleriesconst Signaler = require('signaleries');
const exit = new Signaler();
exit.before([function(){
// logic code
process.exit(0); // exit with the success code
}]);
// also: exit.before(fn1, context); context default: null
// exit.before(fn2, context);
exit.SIGTERM(); // start to listen the signal of sigterm
// also work if the lowerEventName specified `true` value
// exit.sigterm();
exit.emit('SIGTERM'/* sigterm */); // Trigger event Also see: Examples
- .before([fn1, fn2], context) - only accept function or function of
Array - .remove(name | index) - remove one with the hook you added
- .names() - show you all names of hook you added
- SIGABRT
- SIGALRM
- SIGHUP
- SIGINT
- SIGTERM
- SIGVTALRM
- SIGXCPU
- SIGXFSZ
- SIGUSR2
- SIGTRAP
- SIGSYS
- SIGQUIT
- SIGIOT
- SIGIO
- SIGPOLL
- SIGPWR
- SIGSTKFLT
- SIGUNUSED