From fd717dff01df58e7db5c87a930526a888d348ace Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Mon, 5 Feb 2024 10:45:28 +0000 Subject: [PATCH] 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 --- services/document-updater/app.js | 2 +- services/document-updater/config/settings.defaults.js | 3 ++- services/filestore/app.js | 2 +- services/filestore/config/settings.defaults.js | 3 ++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/document-updater/app.js b/services/document-updater/app.js index 901a4eea8e..7fa9743779 100644 --- a/services/document-updater/app.js +++ b/services/document-updater/app.js @@ -217,7 +217,7 @@ const shutdownCleanly = signal => () => { setTimeout(() => { logger.info({ signal }, 'shutting down') process.exit() - }, Settings.delayShutdownMs) + }, Settings.gracefulShutdownDelayInMs) } const watchForEvent = eventName => { diff --git a/services/document-updater/config/settings.defaults.js b/services/document-updater/config/settings.defaults.js index 9f4ce7bc8b..338edb743f 100755 --- a/services/document-updater/config/settings.defaults.js +++ b/services/document-updater/config/settings.defaults.js @@ -168,5 +168,6 @@ module.exports = { continuousBackgroundFlush: process.env.CONTINUOUS_BACKGROUND_FLUSH === 'true', 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, } diff --git a/services/filestore/app.js b/services/filestore/app.js index 360f16da18..ad681ba436 100644 --- a/services/filestore/app.js +++ b/services/filestore/app.js @@ -192,7 +192,7 @@ function handleShutdownSignal(signal) { setTimeout(() => { logger.info({ signal }, 'shutting down') process.exit() - }, settings.delayShutdownMs) + }, settings.gracefulShutdownDelayInMs) } process.on('SIGTERM', handleShutdownSignal) diff --git a/services/filestore/config/settings.defaults.js b/services/filestore/config/settings.defaults.js index 9632d3c4a7..cc97974c32 100644 --- a/services/filestore/config/settings.defaults.js +++ b/services/filestore/config/settings.defaults.js @@ -113,7 +113,8 @@ const settings = { 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