mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge branch 'bg-status-on-shutdown'
This commit is contained in:
commit
a7a161556f
3 changed files with 14 additions and 5 deletions
|
@ -58,7 +58,10 @@ app.get "/", (req, res, next) ->
|
|||
res.send "real-time-sharelatex is alive"
|
||||
|
||||
app.get "/status", (req, res, next) ->
|
||||
res.send "real-time-sharelatex is alive"
|
||||
if Settings.shutDownInProgress
|
||||
res.send 503 # Service unavailable
|
||||
else
|
||||
res.send "real-time-sharelatex is alive"
|
||||
|
||||
app.get "/debug/events", (req, res, next) ->
|
||||
Settings.debugEvents = parseInt(req.query?.count,10) || 20
|
||||
|
@ -116,17 +119,17 @@ shutdownCleanly = (signal) ->
|
|||
shutdownCleanly(signal)
|
||||
, 10000
|
||||
|
||||
shutDownInProgress = false
|
||||
Settings.shutDownInProgress = false
|
||||
if Settings.shutdownDrainTimeWindow?
|
||||
Settings.forceDrainMsDelay = parseInt(Settings.shutdownDrainTimeWindow, 10)
|
||||
logger.log shutdownDrainTimeWindow: Settings.shutdownDrainTimeWindow,"shutdownDrainTimeWindow enabled"
|
||||
for signal in ['SIGINT', 'SIGHUP', 'SIGQUIT', 'SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGABRT']
|
||||
process.on signal, ->
|
||||
if shutDownInProgress
|
||||
if Settings.shutDownInProgress
|
||||
logger.log signal: signal, "shutdown already in progress, ignoring signal"
|
||||
return
|
||||
else
|
||||
shutDownInProgress = true
|
||||
Settings.shutDownInProgress = true
|
||||
logger.log signal: signal, "received interrupt, starting drain over #{Settings.shutdownDrainTimeWindow} mins"
|
||||
DrainManager.startDrainTimeWindow(io, Settings.shutdownDrainTimeWindow)
|
||||
shutdownCleanly(signal)
|
||||
|
|
|
@ -40,7 +40,8 @@ module.exports = DocumentUpdaterManager =
|
|||
logger.log project_id:project_id, "deleting project from document updater"
|
||||
timer = new metrics.Timer("delete.mongo.project")
|
||||
# flush the project in the background when all users have left
|
||||
url = "#{settings.apis.documentupdater.url}/project/#{project_id}?background=true"
|
||||
url = "#{settings.apis.documentupdater.url}/project/#{project_id}?background=true" +
|
||||
(if settings.shutDownInProgress then "&shutdown=true" else "")
|
||||
request.del url, (err, res, body)->
|
||||
timer.done()
|
||||
if err?
|
||||
|
|
|
@ -39,6 +39,11 @@ module.exports = Router =
|
|||
app.post "/drain", httpAuth, HttpApiController.startDrain
|
||||
|
||||
session.on 'connection', (error, client, session) ->
|
||||
if settings.shutDownInProgress
|
||||
client.emit("connectionRejected", {message: "retry"})
|
||||
client.disconnect()
|
||||
return
|
||||
|
||||
if client? and error?.message?.match(/could not look up session by key/)
|
||||
logger.warn err: error, client: client?, session: session?, "invalid session"
|
||||
# tell the client to reauthenticate if it has an invalid session key
|
||||
|
|
Loading…
Reference in a new issue