mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
delay closing by 1 minute for deployment flip
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user