mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
delay closing by 1 minute for deployment flip
This commit is contained in:
parent
17e3068499
commit
32184330d9
2 changed files with 7 additions and 1 deletions
|
@ -85,7 +85,7 @@ io.configure(function () {
|
|||
// a 200 response on '/' is required for load balancer health checks
|
||||
// these operate separately from kubernetes readiness checks
|
||||
app.get('/', function (req, res) {
|
||||
if (Settings.serviceIsClosed || Settings.shutDownInProgress) {
|
||||
if (Settings.shutDownInProgress || DeploymentManager.deploymentIsClosed()) {
|
||||
res.sendStatus(503) // Service unavailable
|
||||
} else {
|
||||
res.send('real-time is open')
|
||||
|
|
|
@ -9,10 +9,13 @@ const FILE_CHECK_INTERVAL = 5000
|
|||
const statusFile = settings.deploymentFile
|
||||
const deploymentColour = settings.deploymentColour
|
||||
|
||||
var serviceCloseTime
|
||||
|
||||
function updateDeploymentStatus(fileContent) {
|
||||
const closed = fileContent && fileContent.indexOf(deploymentColour) === -1
|
||||
if (closed && !settings.serviceIsClosed) {
|
||||
settings.serviceIsClosed = true
|
||||
serviceCloseTime = Date.now() + 60 * 1000 // delay closing by 1 minute
|
||||
logger.warn({ fileContent }, 'closing service')
|
||||
} else if (!closed && settings.serviceIsClosed) {
|
||||
settings.serviceIsClosed = false
|
||||
|
@ -49,5 +52,8 @@ module.exports = {
|
|||
checkStatusFileSync() // perform an initial synchronous check at start up
|
||||
setInterval(pollStatusFile, FILE_CHECK_INTERVAL) // continue checking periodically
|
||||
}
|
||||
},
|
||||
deploymentIsClosed() {
|
||||
return settings.serviceIsClosed && Date.now() > serviceCloseTime
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue