🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

gracefully

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gracefully

Stop a node server gracefully

latest
Source
npmnpm
Version
3.1.1
Version published
Maintainers
1
Created
Source

gracefully

gracefully is a utility function that allow you to shutdown an application ... gracefully.

const gracefully = require("gracefully");
// or use import, it includes typescript types!
gracefully(shutdown, options);
  • shutdown is a function returning a promise. The function gets as a first argument a string with the "reason". That can be either: "SIGINT, SIGTERM, the string defined in customEvent, uncaughtException and unhandledRejection".
  • options: see the following section.

Options:

  • exitDelay (default 50): after shutting down, it waits a certain amount of time before calling process.exit
  • stopWindow: (default: 5000): if the shutdown function takes more than this time, the process exit anyway
  • customEvent (optional): onTerminate listen to this event (emitted by the process), to shutdown the process
  • handleExceptions ( default false): uncaughtException and unhandledRejection are handled in the same way.

signals and events handled

Gracefully will handle SIGINT and SIGTERM signals (and uncaughtException, unhandledRejection), as well as a custom event emitted on process. On receiving them, it will run the shutdown function and end the process when the promise returned is either rejected or fulfilled.

FAQs

Package last updated on 08 Sep 2023

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