Эх сурвалжийг харах

run health check max 1 a at a time

Henry Oswald 9 жил өмнө
parent
commit
bf93fc3f50

+ 6 - 3
services/filestore/app/coffee/HealthCheckController.coffee

@@ -25,7 +25,6 @@ checkCanStoreFiles = (callback)->
 
 
 checkFileConvert = (callback)->
 checkFileConvert = (callback)->
 	imgPath = path.join(settings.path.uploadFolder, "/tiny.pdf")
 	imgPath = path.join(settings.path.uploadFolder, "/tiny.pdf")
-	console.log imgPath, settings.path.uploadFolder
 	async.waterfall [
 	async.waterfall [
 		(cb)->
 		(cb)->
 			fs.copy("./tiny.pdf", imgPath, cb)
 			fs.copy("./tiny.pdf", imgPath, cb)
@@ -37,14 +36,18 @@ checkFileConvert = (callback)->
 
 
 isOk = true
 isOk = true
 
 
+q = async.queue (task, callback)->
+	task(callback)
 
 
-runCheckInBackground = ->
+
+runChecks = (callback)->
 	async.parallel [checkFileConvert, checkCanStoreFiles], (err)->
 	async.parallel [checkFileConvert, checkCanStoreFiles], (err)->
 		if err? 
 		if err? 
 			logger.err err:err, "Health check: error running"
 			logger.err err:err, "Health check: error running"
 			isOk = false
 			isOk = false
 		else
 		else
 			isOk = true
 			isOk = true
+		callback()
 
 
 module.exports =
 module.exports =
 
 
@@ -53,4 +56,4 @@ module.exports =
 			res.send 200
 			res.send 200
 		else
 		else
 			res.send 500
 			res.send 500
-		runCheckInBackground()
+		q.push runChecks # run in background 1 at a time