0.0.7 • Published 10 years ago

graceful-terminate v0.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
10 years ago

graceful-terminate

Gracefully shutdown your node app. Graceful interrupts SIGTERM and SIGINT signals.

Usage

var graceful = require("graceful-terminate");

Cleanup before exit.

graceful.add(() => console.log("Cleaning up."));
^CCleaning up.
$

Prevent shutdown. Return true in the function.

graceful.add(() => {
    ... // check some conditions
    if (notReady()){
        console.log("Cannot terminate yet");
        return true; // don't shutdown.
    }
    return false; // shutdown
});
^CCannot terminate yet.

You can add multiple functions. Return true in any function to prevent shutdown and stop executing other functions.

graceful.add(() => console.log("Cleaning up."));
graceful.add(() => {
    console.log("Shutdown stops here.");
    return true;
}
graceful.add(() => console.log("Won't get here"));
^CCleaning up.
Shutdown stops here.

License

MIT

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago