Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

graceful-terminate

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graceful-terminate

Gracefully shutdown your node app.

  • 0.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 11 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc