Skip to content

serby/express-graceful-shutdown

Repository files navigation

express-graceful-shutdown

Ensure that during shutdown express returns correctly with a 503

build status

Installation

npm install express-graceful-shutdown --save

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: 30000.

Usage

var express = require('express'),
  app = express(),
  createGracefulShutdownMiddleware = require('express-graceful-shutdown'),
  http = require('http'),
  server = http.createServer(app)

app.use(createGracefulShutdownMiddleware(server, { forceTimeout: 30000 }))

app.get('/', function(req, res) {
  res.json({ foo: 'bar' })
})

server.listen(3000)

Prettier

This project uses prettier for code formatting and linting. You can set prettier up to auto format code in your editor, or manually format code before committing with yarn prettier.

Credits

Paul Serby follow me on twitter @serby

License

Licensed under the ISC

About

Ensure that during shutdown express returns correctly with a 503

Resources

License

Stars

Watchers

Forks

Packages

No packages published