mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-01 13:32:15 -05:00
add a double message check
This commit is contained in:
parent
119ae80853
commit
917ce27a2c
1 changed files with 6 additions and 1 deletions
|
@ -26,6 +26,7 @@ module.exports = RedisSharelatex =
|
||||||
pub = RedisSharelatex.createClient(connectionInfo)
|
pub = RedisSharelatex.createClient(connectionInfo)
|
||||||
|
|
||||||
redisIsOk = true
|
redisIsOk = true
|
||||||
|
lastPingMessage = ""
|
||||||
heartbeatInterval = 2000 #ms
|
heartbeatInterval = 2000 #ms
|
||||||
isAliveTimeout = 10000 #ms
|
isAliveTimeout = 10000 #ms
|
||||||
|
|
||||||
|
@ -37,11 +38,15 @@ module.exports = RedisSharelatex =
|
||||||
if error?
|
if error?
|
||||||
console.error "ERROR: failed to subscribe to #{heartbeatChannel} channel", error
|
console.error "ERROR: failed to subscribe to #{heartbeatChannel} channel", error
|
||||||
sub.on "message", (channel, message) ->
|
sub.on "message", (channel, message) ->
|
||||||
|
if lastPingMessage == message #we got the same message twice
|
||||||
|
redisIsOk = false
|
||||||
|
lastPingMessage = message
|
||||||
if channel == heartbeatChannel
|
if channel == heartbeatChannel
|
||||||
lastHeartbeat = Date.now()
|
lastHeartbeat = Date.now()
|
||||||
|
|
||||||
setInterval ->
|
setInterval ->
|
||||||
pub.publish heartbeatChannel, "PING"
|
message = "ping:#{Date.now()}"
|
||||||
|
pub.publish heartbeatChannel, message
|
||||||
, heartbeatInterval
|
, heartbeatInterval
|
||||||
|
|
||||||
isAlive = ->
|
isAlive = ->
|
||||||
|
|
Loading…
Reference in a new issue