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

amazing-grace

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

amazing-grace

A tiny ExpressJS middleware for a sweet, graceful shutdown procedure

  • 2.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

amazing-grace

Build Status

A tiny middleware for a sweet graceful shutdown procedure. Just listen to amazing Grace while closing the app. Existing connections will be respected during a configurable timeout while new ones are being refused.

This middleware is recommended if you want to harden your nodejs app for zero down time during production.

Example

var amazingGrace    = require('amazing-grace'),
    express         = require('express'),

    app    = express(),
    server = http.createServer(app)

// Pass on server instance, required parameter
app.use(amazingGrace(server))

What happens on app.kill('...')?

A graceful shutdown procedure is being initiated, asking the server to close and forcing to close all existing connections after a given timeout so that they have a chance to i.E. save data before oblivion.

During that timeout, new connections to the server won't be possible. After that timeout process.kill(...) is called and the server is shut down.

Options (example)

app.use(amazingGrace(server, {log: console.log, timeout: 50}))

log

Default: none

If you wish more debug information, you can pass on the log function directly i.E. console.log or even bunyan.info.bind(bunyan), whatever log level you wish. Use of bind() is recommended.

timeout

Default: 100ms

Depending on your app performance you might want to increase that to make sure no data loss occurs between restarts.

License

MIT. Copyright (C) Michael Heuberger

Keywords

FAQs

Package last updated on 20 Oct 2020

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