https://github.com/danielsss/signals
Adding salt before node process exit
https://github.com/danielsss/signals
Last synced: 4 months ago
JSON representation
Adding salt before node process exit
- Host: GitHub
- URL: https://github.com/danielsss/signals
- Owner: danielsss
- License: mit
- Created: 2019-03-05T08:09:16.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-10-18T20:22:05.000Z (over 2 years ago)
- Last Synced: 2025-10-10T16:23:34.979Z (8 months ago)
- Language: JavaScript
- Homepage: https://github.com/danielsss/signals
- Size: 854 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/danielsss/signals)
[](https://www.codacy.com/app/danielsss/signals?utm_source=github.com&utm_medium=referral&utm_content=danielsss/signals&utm_campaign=Badge_Grade)
[](https://www.codacy.com/app/danielsss/signals?utm_source=github.com&utm_medium=referral&utm_content=danielsss/signals&utm_campaign=Badge_Coverage)
# Signal salt
adding salt before node process exit
## Dependencies
Node.js version >= 7.0.\*
## Installation
```shell
npm i --save signaleries
```
## Usage
```js
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](test/__example__)
## 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**