From 6f5d068eb05d92ee9c690937330844e2c339f1e1 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 5 Jun 2014 15:51:24 +0100 Subject: [PATCH] added caching of health checks so we can hit them heaviy from multiple places without potential concurency problems --- app.coffee | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app.coffee b/app.coffee index a17894e..ea5bfe8 100644 --- a/app.coffee +++ b/app.coffee @@ -41,7 +41,18 @@ app.get "/project/:project_id/output/*", (req, res, next) -> app.get "/status", (req, res, next) -> res.send "CLSI is alive\n" -app.get "/health_check", smokeTest.run(require.resolve(__dirname + "/test/smoke/js/SmokeTests.js")) +resCacher = + contentType:(@setContentType)-> + send:(@code, @body)-> + +do runSmokeTest = -> + logger.log("running smoke tests") + smokeTest.run(require.resolve(__dirname + "/test/smoke/js/SmokeTests.js"))({}, resCacher) + setTimeout(runSmokeTest, 20 * 1000) + +app.get "/health_check", (req, res)-> + res.contentType(resCacher.setContentType) + res.send resCacher.code, resCacher.body app.use (error, req, res, next) -> logger.error err: error, "server error"