added a /health_check/mongo endpoint

This commit is contained in:
Henry Oswald 2018-08-29 10:35:42 +01:00
parent 6a04800f70
commit 360618a7d3
2 changed files with 18 additions and 0 deletions

View file

@ -5,6 +5,7 @@ rclient = RedisWrapper.client("health_check")
settings = require("settings-sharelatex")
logger = require "logger-sharelatex"
domain = require "domain"
UserGetter = require("../User/UserGetter")
module.exports = HealthCheckController =
check: (req, res, next = (error) ->) ->
@ -37,6 +38,20 @@ module.exports = HealthCheckController =
res.sendStatus 500
else
res.sendStatus 200
checkMongo: (req, res, next)->
logger.log "running mongo health check"
UserGetter.getUserEmail settings.smokeTest.userId, (err, email)->
if err?
logger.err err:err, "mongo health check failed, error present"
return res.sendStatus 500
else if !email?
logger.err err:err, "mongo health check failed, no emai present in find result"
return res.sendStatus 500
else
logger.log email:email, "mongo health check passed"
res.sendStatus 200
Reporter = (res) ->
(runner) ->

View file

@ -359,6 +359,9 @@ module.exports = class Router
publicApiRouter.get '/health_check/redis', HealthCheckController.checkRedis
privateApiRouter.get '/health_check/redis', HealthCheckController.checkRedis
publicApiRouter.get '/health_check/mongo', HealthCheckController.checkMongo
privateApiRouter.get '/health_check/mongo', HealthCheckController.checkMongo
webRouter.get "/status/compiler/:Project_id", AuthorizationMiddlewear.ensureUserCanReadProject, (req, res) ->
project_id = req.params.Project_id
sendRes = _.once (statusCode, message)->