Skip to content

Commit

Permalink
https://github.com/mpneuried/rsmq-worker/issues/15
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Turner committed Jun 18, 2016
1 parent b72e124 commit b13f8b1
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions _src/lib/rsmq-worker.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -228,24 +228,25 @@ class RSMQWorker extends require( "mpbasic" )()
@reconnectActive = false

# handle redis disconnect
@queue.on "disconnect", ( err )=>
@warning "redis connection lost"
_interval = @timeout?
if not @reconnectActive
@reconnectActive = true
@stop() if _interval

# on reconnect
@queue.once "connect", =>
@waitCount = 0
@reconnectActive = false
@queue = new @_getRsmq( true )
@_runOfflineMessages()
@interval() if _interval
@warning "redis connection reconnected"
return
if @queue.listeners("disconnect").length==0
@queue.on "disconnect", ( err )=>
@warning "redis connection lost"
_interval = @timeout?
if not @reconnectActive
@reconnectActive = true
@stop() if _interval

# on reconnect
@queue.once "connect", =>
@waitCount = 0
@reconnectActive = false
@queue = new @_getRsmq( true )
@_runOfflineMessages()
@interval() if _interval
@warning "redis connection reconnected"
return

return
return
if @queue.connected
@_initQueue()
else
Expand Down

0 comments on commit b13f8b1

Please sign in to comment.