Add shutdown middleware to prevent requests
This commit is contained in:
parent
61f19ae3ce
commit
61672c3f1e
1 changed files with 6 additions and 0 deletions
|
@ -121,6 +121,7 @@ var expressOptions = require('./expressOptions')
|
|||
var favicon = require('serve-favicon');
|
||||
|
||||
// express
|
||||
app.use(safeShutdownGuard)
|
||||
app.use(session)
|
||||
app.use(myutil.basicAuth)
|
||||
if (config.accesslog) app.use(logger('common'))
|
||||
|
@ -205,6 +206,11 @@ var shutdownMode = false
|
|||
var shutdownInterval = 0
|
||||
var connectionCount = 0
|
||||
|
||||
function safeShutdownGuard (req, res, next) {
|
||||
if (shutdownMode) res.status(503).end('Service unavailable: Server shutting down')
|
||||
else return next()
|
||||
}
|
||||
|
||||
io.on('connection', function (socket) {
|
||||
connectionCount++
|
||||
|
||||
|
|
Loading…
Reference in a new issue