add continuous background flush

This commit is contained in:
Brian Gough
2019-09-30 16:05:53 +01:00
parent 89a90399fe
commit 73b4262186
3 changed files with 18 additions and 1 deletions
+5
View File
@@ -14,6 +14,7 @@ if Settings.sentry?.dsn?
RedisManager = require('./app/js/RedisManager')
DispatchManager = require('./app/js/DispatchManager')
DeleteQueueManager = require('./app/js/DeleteQueueManager')
Errors = require "./app/js/Errors"
HttpController = require "./app/js/HttpController"
mongojs = require "./app/js/mongojs"
@@ -146,3 +147,7 @@ module.exports = app
for signal in ['SIGINT', 'SIGHUP', 'SIGQUIT', 'SIGUSR1', 'SIGUSR2', 'SIGTERM', 'SIGABRT']
process.on signal, shutdownCleanly(signal)
if Settings.continuousBackgroundFlush
logger.info "Starting continuous background flush"
DeleteQueueManager.startBackgroundFlush()
@@ -1,3 +1,4 @@
Settings = require('settings-sharelatex')
RedisManager = require "./RedisManager"
ProjectManager = require "./ProjectManager"
logger = require "logger-sharelatex"
@@ -60,4 +61,13 @@ module.exports = DeleteQueueManager =
count++ if flushed
flushNextProject()
flushNextProject()
flushNextProject()
startBackgroundFlush: () ->
doFlush = () ->
if Settings.shuttingDown
logger.warn "discontinuing background flush due to shutdown"
return
DeleteQueueManager.flushAndDeleteOldProjects {timeout:1000,min_delete_age:3*60*1000,limit:1000}, () ->
setTimeout doFlush, 10
doFlush()
@@ -95,3 +95,5 @@ module.exports =
dsn: process.env.SENTRY_DSN
publishOnIndividualChannels: process.env['PUBLISH_ON_INDIVIDUAL_CHANNELS'] or false
continuousBackgroundFlush: process.env['CONTINUOUS_BACKGROUND_FLUSH'] or false