mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:03:43 -05:00
Merge pull request #37 from sharelatex/ho-continual-pub-sub-traffic
setup continualPubsubTraffic to keep pub sub happy
This commit is contained in:
commit
5119db43a7
4 changed files with 31 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
Metrics = require("metrics-sharelatex")
|
Metrics = require("metrics-sharelatex")
|
||||||
Settings = require "settings-sharelatex"
|
Settings = require "settings-sharelatex"
|
||||||
Metrics.initialize(Settings.appName or "real-time")
|
Metrics.initialize(Settings.appName or "real-time")
|
||||||
|
async = require("async")
|
||||||
|
|
||||||
logger = require "logger-sharelatex"
|
logger = require "logger-sharelatex"
|
||||||
logger.initialize("real-time")
|
logger.initialize("real-time")
|
||||||
|
@ -115,3 +116,27 @@ if Settings.forceDrainMsDelay?
|
||||||
logger.log signal: signal, "received interrupt, cleaning up"
|
logger.log signal: signal, "received interrupt, cleaning up"
|
||||||
shutdownCleanly(signal)
|
shutdownCleanly(signal)
|
||||||
forceDrain()
|
forceDrain()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if Settings.continualPubsubTraffic
|
||||||
|
console.log "continualPubsubTraffic enabled"
|
||||||
|
|
||||||
|
pubSubClient = redis.createClient(Settings.redis.documentupdater)
|
||||||
|
|
||||||
|
publishJob = (channel, cb)->
|
||||||
|
json = JSON.stringify({health_check:true, date: new Date().toString()})
|
||||||
|
logger.debug {channel:channel}, "sending pub to keep connection alive"
|
||||||
|
pubSubClient.publish channel, json, (err)->
|
||||||
|
if err?
|
||||||
|
logger.err {err, channel}, "error publishing pubsub traffic to redis"
|
||||||
|
cb(err)
|
||||||
|
|
||||||
|
runPubSubTraffic = ->
|
||||||
|
async.map ["applied-ops", "editor-events"], publishJob, (err)->
|
||||||
|
setTimeout(runPubSubTraffic, 1000 * 60)
|
||||||
|
|
||||||
|
runPubSubTraffic()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,8 @@ module.exports = DocumentUpdaterController =
|
||||||
DocumentUpdaterController._applyUpdateFromDocumentUpdater(io, message.doc_id, message.op)
|
DocumentUpdaterController._applyUpdateFromDocumentUpdater(io, message.doc_id, message.op)
|
||||||
else if message.error?
|
else if message.error?
|
||||||
DocumentUpdaterController._processErrorFromDocumentUpdater(io, message.doc_id, message.error, message)
|
DocumentUpdaterController._processErrorFromDocumentUpdater(io, message.doc_id, message.error, message)
|
||||||
|
else if message.health_check?
|
||||||
|
logger.debug {message}, "got health check message in applied ops channel"
|
||||||
|
|
||||||
_applyUpdateFromDocumentUpdater: (io, doc_id, update) ->
|
_applyUpdateFromDocumentUpdater: (io, doc_id, update) ->
|
||||||
for client in io.sockets.clients(doc_id)
|
for client in io.sockets.clients(doc_id)
|
||||||
|
|
|
@ -37,4 +37,6 @@ module.exports = WebsocketLoadBalancer =
|
||||||
io.sockets.emit(message.message, message.payload...)
|
io.sockets.emit(message.message, message.payload...)
|
||||||
else if message.room_id?
|
else if message.room_id?
|
||||||
io.sockets.in(message.room_id).emit(message.message, message.payload...)
|
io.sockets.in(message.room_id).emit(message.message, message.payload...)
|
||||||
|
else if message.health_check?
|
||||||
|
logger.debug {message}, "got health check message in editor events channel"
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ settings =
|
||||||
|
|
||||||
forceDrainMsDelay: process.env['FORCE_DRAIN_MS_DELAY'] or false
|
forceDrainMsDelay: process.env['FORCE_DRAIN_MS_DELAY'] or false
|
||||||
|
|
||||||
|
continualPubsubTraffic: process.env['CONTINUAL_PUBSUB_TRAFFIC'] or false
|
||||||
|
|
||||||
|
|
||||||
# console.log settings.redis
|
# console.log settings.redis
|
||||||
module.exports = settings
|
module.exports = settings
|
Loading…
Reference in a new issue