Merge pull request #2633 from overleaf/bg-fix-health-check-for-web-api

fix the health check on the api router

GitOrigin-RevId: 985322f8e4ff0b5dddbe7cf68c41414af6fd502d
This commit is contained in:
Brian Gough 2020-03-10 14:24:12 +00:00 committed by Copybot
parent 8547bb3c8d
commit fc028c7544
2 changed files with 21 additions and 1 deletions

View file

@ -57,6 +57,26 @@ module.exports = HealthCheckController = {
})
},
checkApi(req, res, next) {
rclient.healthCheck(err => {
if (err) {
logger.err({ err }, 'failed api redis health check')
return res.sendStatus(500)
}
UserGetter.getUserEmail(settings.smokeTest.userId, (err, email) => {
if (err) {
logger.err({ err }, 'failed api mongo health check')
return res.sendStatus(500)
}
if (email == null) {
logger.err({ err }, 'failed api mongo health check (no email)')
return res.sendStatus(500)
}
res.sendStatus(200)
})
})
},
checkRedis(req, res, next) {
return rclient.healthCheck(function(error) {
if (error != null) {

View file

@ -969,7 +969,7 @@ function initialize(webRouter, privateApiRouter, publicApiRouter) {
webRouter.get('/dev/csrf', (req, res) => res.send(res.locals.csrfToken))
publicApiRouter.get('/health_check', HealthCheckController.check)
privateApiRouter.get('/health_check', HealthCheckController.check)
privateApiRouter.get('/health_check', HealthCheckController.checkApi)
publicApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)
privateApiRouter.get('/health_check/redis', HealthCheckController.checkRedis)