mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
run flush of queued projects in the background
This commit is contained in:
parent
ba35c73cb6
commit
fc62abfcfa
2 changed files with 8 additions and 8 deletions
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue