Merge pull request #9099 from overleaf/jpa-web-graceful-shutdown

[web] introduce graceful shutdown

GitOrigin-RevId: f42793a96f1e0304c57a855241bffa32bb291864
This commit is contained in:
Jakob Ackermann
2022-08-05 08:03:27 +00:00
committed by Copybot
parent ab4a01f15b
commit e5e6be99f8
16 changed files with 273 additions and 35 deletions
@@ -11,6 +11,9 @@
*/
let SystemMessageManager
const { SystemMessage } = require('../../models/SystemMessage')
const {
addRequiredCleanupHandlerBeforeDrainingConnections,
} = require('../../infrastructure/GracefulShutdown')
module.exports = SystemMessageManager = {
getMessages(callback) {
@@ -53,4 +56,14 @@ module.exports = SystemMessageManager = {
const CACHE_TIMEOUT = 10 * 1000 * (Math.random() + 2) // 20-30 seconds
SystemMessageManager.refreshCache()
setInterval(() => SystemMessageManager.refreshCache(), CACHE_TIMEOUT)
const intervalHandle = setInterval(
() => SystemMessageManager.refreshCache(),
CACHE_TIMEOUT
)
addRequiredCleanupHandlerBeforeDrainingConnections(
'update system messages',
() => {
clearInterval(intervalHandle)
}
)