mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Add in http health check end points for redis subscription channels
This commit is contained in:
parent
34e20e99f5
commit
8b9a26d6f3
5 changed files with 23 additions and 4 deletions
|
@ -1,12 +1,15 @@
|
|||
Settings = require 'settings-sharelatex'
|
||||
redis = require("redis-sharelatex")
|
||||
rclientPub = redis.createClient(Settings.redis.web)
|
||||
rclientSub = redis.createRobustSubscriptionClient(Settings.redis.web)
|
||||
rclientSub = redis.createMonitoredSubscriptionClient(Settings.redis.web)
|
||||
|
||||
module.exports = EditorRealTimeController =
|
||||
rclientPub: rclientPub
|
||||
rclientSub: rclientSub
|
||||
|
||||
isRedisPubSubAlive: () ->
|
||||
rclientSub.isAlive()
|
||||
|
||||
emitToRoom: (room_id, message, payload...) ->
|
||||
@rclientPub.publish "editor-events", JSON.stringify
|
||||
room_id: room_id
|
||||
|
|
|
@ -5,7 +5,7 @@ redis = require("redis-sharelatex")
|
|||
DocumentUpdaterHandler = require('../DocumentUpdater/DocumentUpdaterHandler')
|
||||
EditorRealTimeController = require("./EditorRealTimeController")
|
||||
|
||||
rclient = redis.createRobustSubscriptionClient(Settings.redis.web)
|
||||
rclient = redis.createMonitoredSubscriptionClient(Settings.redis.web)
|
||||
|
||||
module.exports = EditorUpdatesController =
|
||||
_applyUpdate: (client, project_id, doc_id, update, callback = (error) ->) ->
|
||||
|
@ -29,6 +29,9 @@ module.exports = EditorUpdatesController =
|
|||
update.meta.user_id = user_id
|
||||
EditorUpdatesController._applyUpdate client, project_id, doc_id, update
|
||||
|
||||
isRedisPubSubAlive: () ->
|
||||
rclient.isAlive()
|
||||
|
||||
listenForUpdatesFromDocumentUpdater: () ->
|
||||
rclient.subscribe "applied-ops"
|
||||
rclient.on "message", (channel, message) ->
|
||||
|
|
|
@ -8,6 +8,7 @@ AuthorizationManager = require('./Features/Security/AuthorizationManager')
|
|||
EditorController = require("./Features/Editor/EditorController")
|
||||
EditorRouter = require("./Features/Editor/EditorRouter")
|
||||
EditorUpdatesController = require("./Features/Editor/EditorUpdatesController")
|
||||
EditorRealTimeController = require("./Features/Editor/EditorRealTimeController")
|
||||
Settings = require('settings-sharelatex')
|
||||
TpdsController = require('./Features/ThirdPartyDataStore/TpdsController')
|
||||
SubscriptionRouter = require './Features/Subscription/SubscriptionRouter'
|
||||
|
@ -176,6 +177,18 @@ module.exports = class Router
|
|||
|
||||
app.get '/health_check', HealthCheckController.check
|
||||
|
||||
app.get '/health_check/redis/doc_updates', (req, res, next) ->
|
||||
if EditorUpdatesController.isRedisPubSubAlive()
|
||||
res.send(200)
|
||||
else
|
||||
res.send(500)
|
||||
|
||||
app.get '/health_check/redis/websockets', (req, res, next) ->
|
||||
if EditorRealTimeController.isRedisPubSubAlive()
|
||||
res.send(200)
|
||||
else
|
||||
res.send(500)
|
||||
|
||||
app.get "/status/compiler/:Project_id", SecurityManager.requestCanAccessProject, (req, res) ->
|
||||
sendRes = _.once (statusCode, message)->
|
||||
res.writeHead statusCode
|
||||
|
|
|
@ -9,7 +9,7 @@ describe "EditorRealTimeController", ->
|
|||
"redis-sharelatex":
|
||||
createClient: () ->
|
||||
auth:->
|
||||
createRobustSubscriptionClient: () ->
|
||||
createMonitoredSubscriptionClient: () ->
|
||||
auth:->
|
||||
"../../infrastructure/Server" : io: @io = {}
|
||||
@EditorRealTimeController.rclientPub = publish: sinon.stub()
|
||||
|
|
|
@ -18,7 +18,7 @@ describe "EditorUpdatesController", ->
|
|||
"../../infrastructure/Metrics" : @metrics = { set: sinon.stub(), inc: sinon.stub() }
|
||||
"../../infrastructure/Server" : io: @io = {}
|
||||
"redis-sharelatex" :
|
||||
createRobustSubscriptionClient: ()=>
|
||||
createMonitoredSubscriptionClient: ()=>
|
||||
@rclient = {auth:->}
|
||||
|
||||
describe "_applyUpdate", ->
|
||||
|
|
Loading…
Reference in a new issue