clean up compile check

use a valid user id, report all failures as errors, clear timeout on
success
This commit is contained in:
Brian Gough 2016-08-31 15:21:23 +01:00
parent c44f33ce99
commit b95a2c6d04

View file

@ -252,13 +252,24 @@ module.exports = class Router
apiRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
sendRes = _.once (statusCode, message)->
res.writeHead statusCode
res.end message
CompileManager.compile req.params.Project_id, "test-compile", {}, () ->
sendRes 200, "Compiler returned in less than 10 seconds"
setTimeout (() ->
res.status statusCode
res.send message
# set a timeout
handler = setTimeout (() ->
sendRes 500, "Compiler timed out"
handler = null
), 10000
# use a valid user id for testing
test_user_id = "123456789012345678901234"
# run the compile
CompileManager.compile req.params.Project_id, test_user_id, {}, (error, status) ->
clearTimeout handler if handler?
if error?
sendRes 500, "Compiler returned error #{error.message}"
else if status is "success"
sendRes 200, "Compiler returned in less than 10 seconds"
else
sendRes 500, "Compiler returned failure #{status}"
apiRouter.get "/ip", (req, res, next) ->
res.send({