Преглед изворни кода

run flush of queued projects in the background

Brian Gough пре 7 година
родитељ
комит
fc62abfcfa

+ 3 - 3
services/document-updater/app/coffee/DeleteQueueManager.coffee

@@ -46,13 +46,13 @@ module.exports = DeleteQueueManager =
             now = Date.now()
             now = Date.now()
             if now - startTime > options.timeout
             if now - startTime > options.timeout
                 logger.log "hit time limit on flushing old projects"
                 logger.log "hit time limit on flushing old projects"
-                return callback()
+                return callback(null, count)
             if count > options.limit
             if count > options.limit
                 logger.log "hit count limit on flushing old projects"
                 logger.log "hit count limit on flushing old projects"
-                return callback()
+                return callback(null, count)
             RedisManager.getNextProjectToFlushAndDelete cutoffTime, (err, project_id, flushTimestamp, queueLength) ->
             RedisManager.getNextProjectToFlushAndDelete cutoffTime, (err, project_id, flushTimestamp, queueLength) ->
                 return callback(err) if err?
                 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"
                 logger.log {project_id, queueLength: queueLength}, "flushing queued project"
                 metrics.globalGauge "queued-flush-backlog", queueLength
                 metrics.globalGauge "queued-flush-backlog", queueLength
                 flushProjectIfNotModified project_id, flushTimestamp, (err, flushed) ->
                 flushProjectIfNotModified project_id, flushTimestamp, (err, flushed) ->

+ 5 - 5
services/document-updater/app/coffee/HttpController.coffee

@@ -216,15 +216,15 @@ module.exports = HttpController =
 				res.send project_ids
 				res.send project_ids
 
 
 	flushQueuedProjects: (req, res, next = (error) ->) ->
 	flushQueuedProjects: (req, res, next = (error) ->) ->
-		res.setTimeout(5 * 60 * 1000)
 		options = 
 		options = 
 			limit : req.query.limit || 1000
 			limit : req.query.limit || 1000
 			timeout: 5 * 60 * 1000
 			timeout: 5 * 60 * 1000
 			dryRun : req.query.dryRun || false
 			dryRun : req.query.dryRun || false
 			min_delete_age: req.query.min_delete_age || 5 * 60 * 1000
 			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?
 			if err?
 				logger.err err:err, "error flushing old projects"
 				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"