danielsss/signals

Adding salt before node process exit

★ 2Forks 0JavaScriptGitHub ↗Compare

Project website ↗

README

Build Status Codacy Badge Codacy Badge

Signal salt

adding salt before node process exit

Dependencies

Node.js version >= 7.0.*

Installation

npm i --save signaleries

Usage

const 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

Methods of signaleries

  • .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

The signals that can be listened

Defaults
  • SIGABRT
  • SIGALRM
  • SIGHUP
  • SIGINT
  • SIGTERM
Non-win32
  • SIGVTALRM
  • SIGXCPU
  • SIGXFSZ
  • SIGUSR2
  • SIGTRAP
  • SIGSYS
  • SIGQUIT
  • SIGIOT
Linux
  • SIGIO
  • SIGPOLL
  • SIGPWR
  • SIGSTKFLT
  • SIGUNUSED

Contributors

danielsssdependabot[bot]

Issues