Ensure that during shutdown express returns correctly with a 503
npm install express-graceful-shutdown --save
logger
: a logger that providesinfo
,warn
, anderror
functions for recording graceful shutdown. Default:console
.forceTimeout
: number of milliseconds to wait forserver.close()
to complete before callingprocess.exit(1)
. Default:30000
.
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)
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
.
Paul Serby follow me on twitter @serby
Licensed under the ISC