Socket
Book a DemoInstallSign in
Socket

@bookmate/with-express-graceful-shutdown

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bookmate/with-express-graceful-shutdown

Decorator for Express apps to enable graceful shutdown

0.0.1
latest
Source
npmnpm
Version published
Weekly downloads
22
15.79%
Maintainers
3
Weekly downloads
 
Created
Source

Graceful Shutdown

Summary

This is a decorator for an Express http server enabling its graceful shutdown.

Based on ideas from:

  • express-graceful-shutdown middleware, which in turn used this blog post for inspiration;

  • http-shutdown module

Installation

npm install @bookmate/with-express-graceful-shutdown --save

Usage

const withGracefulShutdown = require('@bookmate/with-express-graceful-shutdown');
const app = require('./app'); // a regular Express app
const logger = require('./logger') // a custom logger

const expressPort = 3000;
const forceTimout = 30 * 1000; // timeout after which the app should be shut down forcefully

const options = {
  logger,
  forceTimout
}

const server = app.listen(expressPort, () => {
  // your server is running
});

withGracefulShutdown(server, options);

Options

  • logger: a logger that provides info, warn, and error functions for recording graceful shutdown. Default: console.

  • forceTimeout: number of milliseconds to wait for server.close() to complete before calling process.exit(1). Default: 60000.

FAQs

Package last updated on 05 Feb 2019

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.