Merge pull request #16888 from overleaf/jpa-faster-filestore-stop-in-dev

[misc] use a common environment variable for the graceful shutdown delay

GitOrigin-RevId: 010e83c62eff7bedac3b10e36e9b4f38d6459a1c
This commit is contained in:
Jakob Ackermann 2024-02-05 10:45:28 +00:00 committed by Copybot
parent 621301618f
commit fd717dff01
4 changed files with 6 additions and 4 deletions

View file

@ -217,7 +217,7 @@ const shutdownCleanly = signal => () => {
setTimeout(() => { setTimeout(() => {
logger.info({ signal }, 'shutting down') logger.info({ signal }, 'shutting down')
process.exit() process.exit()
}, Settings.delayShutdownMs) }, Settings.gracefulShutdownDelayInMs)
} }
const watchForEvent = eventName => { const watchForEvent = eventName => {

View file

@ -168,5 +168,6 @@ module.exports = {
continuousBackgroundFlush: process.env.CONTINUOUS_BACKGROUND_FLUSH === 'true', continuousBackgroundFlush: process.env.CONTINUOUS_BACKGROUND_FLUSH === 'true',
smoothingOffset: process.env.SMOOTHING_OFFSET || 1000, // milliseconds smoothingOffset: process.env.SMOOTHING_OFFSET || 1000, // milliseconds
delayShutdownMs: parseInt(process.env.DELAY_SHUTDOWN_MS || '10000', 10), gracefulShutdownDelayInMs:
parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '10', 10) * 1000,
} }

View file

@ -192,7 +192,7 @@ function handleShutdownSignal(signal) {
setTimeout(() => { setTimeout(() => {
logger.info({ signal }, 'shutting down') logger.info({ signal }, 'shutting down')
process.exit() process.exit()
}, settings.delayShutdownMs) }, settings.gracefulShutdownDelayInMs)
} }
process.on('SIGTERM', handleShutdownSignal) process.on('SIGTERM', handleShutdownSignal)

View file

@ -113,7 +113,8 @@ const settings = {
dsn: process.env.SENTRY_DSN, dsn: process.env.SENTRY_DSN,
}, },
delayShutdownMs: parseInt(process.env.DELAY_SHUTDOWN_MS || '30000', 10), gracefulShutdownDelayInMs:
parseInt(process.env.GRACEFUL_SHUTDOWN_DELAY_SECONDS ?? '30', 10) * 1000,
} }
// Filestore health check // Filestore health check