mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 14:13:43 +01:00
added redis write check to healthcheck
This commit is contained in:
@@ -47,6 +47,8 @@ app.post "/pack", (req, res, next) ->
|
||||
app.get "/status", (req, res, next) ->
|
||||
res.send "track-changes is alive"
|
||||
|
||||
app.get "/check_lock", HttpController.checkLock
|
||||
|
||||
app.get "/health_check", HttpController.healthCheck
|
||||
|
||||
app.use (error, req, res, next) ->
|
||||
|
||||
@@ -11,6 +11,14 @@ module.exports =
|
||||
url = "http://localhost:#{port}/project/#{project_id}"
|
||||
logger.log project_id:project_id, "running health check"
|
||||
jobs = [
|
||||
(cb)->
|
||||
request.get {url:"http://localhost:#{port}/check_lock", timeout:3000}, (err, res, body) ->
|
||||
if err?
|
||||
cb(err)
|
||||
else if res?.statusCode != 200
|
||||
cb("status code not 200, it's #{res.statusCode}")
|
||||
else
|
||||
cb()
|
||||
(cb)->
|
||||
request.post {url:"#{url}/flush", timeout:3000}, (err, res, body) ->
|
||||
if err?
|
||||
|
||||
@@ -5,6 +5,7 @@ RestoreManager = require "./RestoreManager"
|
||||
logger = require "logger-sharelatex"
|
||||
DocArchiveManager = require "./DocArchiveManager"
|
||||
HealthChecker = require "./HealthChecker"
|
||||
LockManager = require "./LockManager"
|
||||
|
||||
module.exports = HttpController =
|
||||
flushDoc: (req, res, next = (error) ->) ->
|
||||
@@ -90,3 +91,11 @@ module.exports = HttpController =
|
||||
res.send 500
|
||||
else
|
||||
res.send 200
|
||||
|
||||
checkLock: (req, res)->
|
||||
LockManager.healthCheck (err) ->
|
||||
if err?
|
||||
logger.err err:err, "error performing lock check"
|
||||
res.send 500
|
||||
else
|
||||
res.send 200
|
||||
|
||||
@@ -66,4 +66,7 @@ module.exports = LockManager =
|
||||
return callback(error) if error?
|
||||
callback()
|
||||
|
||||
|
||||
healthCheck: (callback) ->
|
||||
action = (releaseLock) ->
|
||||
releaseLock()
|
||||
LockManager.runWithLock "HistoryLock:HealthCheck:host=#{HOST}:pid=#{PID}:random=#{RND}", action, callback
|
||||
|
||||
Reference in New Issue
Block a user