mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-25 16:00:59 +00:00
add /debug/events endpoint
This commit is contained in:
parent
2a31139254
commit
c6225d614e
4 changed files with 16 additions and 0 deletions
|
@ -53,6 +53,11 @@ app.get "/", (req, res, next) ->
|
|||
app.get "/status", (req, res, next) ->
|
||||
res.send "real-time-sharelatex is alive"
|
||||
|
||||
app.get "/debug/events", (req, res, next) ->
|
||||
Settings.debugEvents = parseInt(req.query?.count,10) || 20
|
||||
logger.log {count: Settings.debugEvents}, "starting debug mode"
|
||||
res.send "debug mode will log next #{Settings.debugEvents} events"
|
||||
|
||||
rclient = require("redis-sharelatex").createClient(Settings.redis.realtime)
|
||||
app.get "/health_check/redis", (req, res, next) ->
|
||||
rclient.healthCheck (error) ->
|
||||
|
|
|
@ -15,6 +15,7 @@ module.exports = DocumentUpdaterController =
|
|||
listenForUpdatesFromDocumentUpdater: (io) ->
|
||||
rclient.subscribe "applied-ops"
|
||||
rclient.on "message", (channel, message) ->
|
||||
EventLogger.debugEvent(channel, message) if settings.debugEvents > 0
|
||||
DocumentUpdaterController._processMessageFromDocumentUpdater(io, channel, message)
|
||||
|
||||
_processMessageFromDocumentUpdater: (io, channel, message) ->
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
logger = require 'logger-sharelatex'
|
||||
metrics = require 'metrics-sharelatex'
|
||||
settings = require 'settings-sharelatex'
|
||||
|
||||
# keep track of message counters to detect duplicate and out of order events
|
||||
# messsage ids have the format "UNIQUEHOSTKEY-COUNTER"
|
||||
|
@ -8,10 +9,18 @@ EVENT_LOG_COUNTER = {}
|
|||
EVENT_LOG_TIMESTAMP = {}
|
||||
EVENT_LAST_CLEAN_TIMESTAMP = 0
|
||||
|
||||
# counter for debug logs
|
||||
COUNTER = 0
|
||||
|
||||
module.exports = EventLogger =
|
||||
|
||||
MAX_STALE_TIME_IN_MS: 3600 * 1000
|
||||
|
||||
debugEvent: (channel, message) ->
|
||||
if settings.debugEvents > 0
|
||||
logger.log {channel:channel, message:message, counter: COUNTER++}, "logging event"
|
||||
settings.debugEvents--
|
||||
|
||||
checkEventOrder: (channel, message_id, message) ->
|
||||
return if typeof(message_id) isnt 'string'
|
||||
return if !(result = message_id.match(/^(.*)-(\d+)$/))
|
||||
|
|
|
@ -27,6 +27,7 @@ module.exports = WebsocketLoadBalancer =
|
|||
listenForEditorEvents: (io) ->
|
||||
@rclientSub.subscribe "editor-events"
|
||||
@rclientSub.on "message", (channel, message) ->
|
||||
EventLogger.debugEvent(channel, message) if Settings.debugEvents > 0
|
||||
WebsocketLoadBalancer._processEditorEvent io, channel, message
|
||||
|
||||
_processEditorEvent: (io, channel, message) ->
|
||||
|
|
Loading…
Reference in a new issue