diff --git a/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee b/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee index b6270cfce9..c237f212c0 100644 --- a/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee +++ b/services/web/app/coffee/Features/Compile/ClsiCookieManager.coffee @@ -48,6 +48,10 @@ module.exports = ClsiCookieManager = multi.exec (err)-> callback(err, serverId) + clearServerId: (project_id, callback = (err)->)-> + if !clsiCookiesEnabled + return callback() + rclient.del buildKey(project_id), callback getCookieJar: (project_id, callback = (err, jar)->)-> if !clsiCookiesEnabled diff --git a/services/web/app/coffee/router.coffee b/services/web/app/coffee/router.coffee index 5d07dc9e82..e6de2e7183 100644 --- a/services/web/app/coffee/router.coffee +++ b/services/web/app/coffee/router.coffee @@ -22,6 +22,7 @@ UserPagesController = require('./Features/User/UserPagesController') DocumentController = require('./Features/Documents/DocumentController') CompileManager = require("./Features/Compile/CompileManager") CompileController = require("./Features/Compile/CompileController") +ClsiCookieManager = require("./Features/Compile/ClsiCookieManager") HealthCheckController = require("./Features/HealthCheck/HealthCheckController") ProjectDownloadsController = require "./Features/Downloads/ProjectDownloadsController" FileStoreController = require("./Features/FileStore/FileStoreController") @@ -251,14 +252,27 @@ module.exports = class Router apiRouter.get '/health_check/redis', HealthCheckController.checkRedis apiRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) -> + project_id = req.params.Project_id 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 + ClsiCookieManager.clearServerId project_id # force every compile to a new server + # 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 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({