https://github.com/abiosoft/node-graceful
Gracefully shutdown your node app. Graceful interrupts SIGTERM and SIGINT signals.
https://github.com/abiosoft/node-graceful
Last synced: 11 months ago
JSON representation
Gracefully shutdown your node app. Graceful interrupts SIGTERM and SIGINT signals.
- Host: GitHub
- URL: https://github.com/abiosoft/node-graceful
- Owner: abiosoft
- License: mit
- Created: 2016-03-11T10:41:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-16T10:15:47.000Z (over 10 years ago)
- Last Synced: 2025-07-12T21:42:07.354Z (11 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# graceful-terminate
Gracefully shutdown your node app. Graceful interrupts `SIGTERM` and `SIGINT` signals.
### Usage
```js
var graceful = require("graceful-terminate");
```
Cleanup before exit.
```js
graceful.add(() => console.log("Cleaning up."));
```
```sh
^CCleaning up.
$
```
Prevent shutdown. Return `true` in the function.
```js
graceful.add(() => {
... // check some conditions
if (notReady()){
console.log("Cannot terminate yet");
return true; // don't shutdown.
}
return false; // shutdown
});
```
```sh
^CCannot terminate yet.
```
You can add multiple functions. Return `true` in any function to prevent shutdown and stop executing other functions.
```js
graceful.add(() => console.log("Cleaning up."));
graceful.add(() => {
console.log("Shutdown stops here.");
return true;
}
graceful.add(() => console.log("Won't get here"));
```
```sh
^CCleaning up.
Shutdown stops here.
```
### License
MIT