mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-22 21:09:42 +00:00
added redis write check to healthcheck
This commit is contained in:
parent
c44d5b1b3d
commit
992857d6a2
4 changed files with 23 additions and 1 deletions
services/track-changes
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue