mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-29 20:11:32 +02:00
run flush of queued projects in the background
This commit is contained in:
@@ -46,13 +46,13 @@ module.exports = DeleteQueueManager =
|
||||
now = Date.now()
|
||||
if now - startTime > options.timeout
|
||||
logger.log "hit time limit on flushing old projects"
|
||||
return callback()
|
||||
return callback(null, count)
|
||||
if count > options.limit
|
||||
logger.log "hit count limit on flushing old projects"
|
||||
return callback()
|
||||
return callback(null, count)
|
||||
RedisManager.getNextProjectToFlushAndDelete cutoffTime, (err, project_id, flushTimestamp, queueLength) ->
|
||||
return callback(err) if err?
|
||||
return callback() if !project_id?
|
||||
return callback(null, count) if !project_id?
|
||||
logger.log {project_id, queueLength: queueLength}, "flushing queued project"
|
||||
metrics.globalGauge "queued-flush-backlog", queueLength
|
||||
flushProjectIfNotModified project_id, flushTimestamp, (err, flushed) ->
|
||||
|
||||
@@ -216,15 +216,15 @@ module.exports = HttpController =
|
||||
res.send project_ids
|
||||
|
||||
flushQueuedProjects: (req, res, next = (error) ->) ->
|
||||
res.setTimeout(5 * 60 * 1000)
|
||||
options =
|
||||
limit : req.query.limit || 1000
|
||||
timeout: 5 * 60 * 1000
|
||||
dryRun : req.query.dryRun || false
|
||||
min_delete_age: req.query.min_delete_age || 5 * 60 * 1000
|
||||
DeleteQueueManager.flushAndDeleteOldProjects options, (err, project_ids)->
|
||||
res.send 204
|
||||
# run the flush in the background
|
||||
DeleteQueueManager.flushAndDeleteOldProjects options, (err, flushed)->
|
||||
if err?
|
||||
logger.err err:err, "error flushing old projects"
|
||||
res.send 500
|
||||
else
|
||||
res.send project_ids
|
||||
else
|
||||
logger.log {flushed: flushed}, "flush of queued projects completed"
|
||||
|
||||
Reference in New Issue
Block a user