mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-26 19:11:56 +00:00
put all shutdown logic in beginShutdown, force program to exit after 2 mins
This commit is contained in:
parent
e8e2338c0c
commit
02101868e1
1 changed files with 9 additions and 7 deletions
|
@ -103,8 +103,6 @@ app.get "/health_check", (req, res)->
|
|||
else
|
||||
res.send(503)
|
||||
|
||||
|
||||
|
||||
app.get '*', (req, res)->
|
||||
res.send 404
|
||||
|
||||
|
@ -115,12 +113,16 @@ host = settings.internal.filestore.host or "localhost"
|
|||
beginShutdown = () ->
|
||||
if appIsOk
|
||||
appIsOk = false
|
||||
server.close()
|
||||
# hard-terminate this process if graceful shutdown fails
|
||||
killTimer = setTimeout () ->
|
||||
process.exit 1
|
||||
, 120*1000
|
||||
killTimer.unref?() # prevent timer from keeping process alive
|
||||
server.close () ->
|
||||
logger.log "closed all connections"
|
||||
Metrics.close()
|
||||
process.disconnect?()
|
||||
logger.log "server will stop accepting connections"
|
||||
|
||||
server.on "close", () ->
|
||||
logger.log "closed all connections"
|
||||
process.exit 1
|
||||
|
||||
server.listen port, host, ->
|
||||
logger.log("filestore store listening on #{host}:#{port}")
|
||||
|
|
Loading…
Reference in a new issue