mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
add a combined health check for mongo and redis
This commit is contained in:
parent
ad485709cf
commit
40f6494b19
2 changed files with 31 additions and 1 deletions
|
@ -16,6 +16,8 @@ RedisManager = require('./app/js/RedisManager')
|
|||
DispatchManager = require('./app/js/DispatchManager')
|
||||
Errors = require "./app/js/Errors"
|
||||
HttpController = require "./app/js/HttpController"
|
||||
mongojs = require "./app/js/mongojs"
|
||||
async = require "async"
|
||||
|
||||
Path = require "path"
|
||||
|
||||
|
@ -92,6 +94,29 @@ app.get "/health_check/redis_cluster", (req, res, next) ->
|
|||
else
|
||||
res.send 200
|
||||
|
||||
app.get "/health_check", (req, res, next) ->
|
||||
async.series [
|
||||
(cb) ->
|
||||
pubsubClient.healthCheck (error) ->
|
||||
if error?
|
||||
logger.err {err: error}, "failed redis health check"
|
||||
cb(error)
|
||||
(cb) ->
|
||||
docUpdaterRedisClient.healthCheck (error) ->
|
||||
if error?
|
||||
logger.err {err: error}, "failed redis cluster health check"
|
||||
cb(error)
|
||||
(cb) ->
|
||||
mongojs.healthCheck (error) ->
|
||||
if error?
|
||||
logger.err {err: error}, "failed mongo health check"
|
||||
cb(error)
|
||||
] , (error) ->
|
||||
if error?
|
||||
res.send 500
|
||||
else
|
||||
res.send 200
|
||||
|
||||
app.use (error, req, res, next) ->
|
||||
if error instanceof Errors.NotFoundError
|
||||
res.send 404
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
Settings = require "settings-sharelatex"
|
||||
mongojs = require "mongojs"
|
||||
db = mongojs(Settings.mongo.url, ["docSnapshots"])
|
||||
|
||||
module.exports =
|
||||
db: db
|
||||
ObjectId: mongojs.ObjectId
|
||||
|
||||
healthCheck: (callback) ->
|
||||
db.runCommand {ping: 1}, (err, res) ->
|
||||
return callback(err) if err?
|
||||
return callback(new Error("failed mongo ping")) if !res.ok
|
||||
callback()
|
||||
|
|
Loading…
Reference in a new issue