if redis fails once mark it to always fail

This commit is contained in:
Henry Oswald 2014-11-20 11:09:44 +00:00
parent e133c7101e
commit ef0ea2ace2

View file

@ -25,6 +25,7 @@ module.exports = RedisSharelatex =
sub = RedisSharelatex.createClient(connectionInfo)
pub = RedisSharelatex.createClient(connectionInfo)
redisIsOk = true
heartbeatInterval = 2000 #ms
isAliveTimeout = 10000 #ms
@ -45,8 +46,11 @@ module.exports = RedisSharelatex =
isAlive = ->
timeSinceLastHeartbeat = Date.now() - lastHeartbeat
if timeSinceLastHeartbeat > isAliveTimeout
if !redisIsOk
return false
else if timeSinceLastHeartbeat > isAliveTimeout
console.error "heartbeat from redis timed out"
redisIsOk = false
return false
else
return true