Skip to content

Commit 509e4c6

Browse files
author
Conor Pappas
committed
Adds documentation and turns on the option for using the disconnect recovery
1 parent 91ba7e8 commit 509e4c6

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

lib/resque_stuck_queue.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ def abort_on_exception
6161
end
6262
end
6363

64+
def disconnect_recovery
65+
if !config[:disconnect_recovery].nil?
66+
config[:disconnect_recovery] # allow overriding w true
67+
else
68+
false # default
69+
end
70+
end
71+
6472
def start_in_background
6573
Thread.new do
6674
Thread.current.abort_on_exception = abort_on_exception
@@ -326,7 +334,7 @@ def handle_redis_disconnect(error_message)
326334
message = error_message.respond_to?(:call) ? error_message.call(e) : error_message
327335
logger.error(message)
328336
logger.error("\n#{e.backtrace.join("\n")}")
329-
raise e unless config[:redis_disconnect_recovery]
337+
raise e unless disconnect_recovery
330338
end
331339
end
332340
end

lib/resque_stuck_queue/config.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,21 @@ module StuckQueue
1919
class Config < Hash
2020

2121
OPTIONS_DESCRIPTIONS = {
22-
:triggered_handler => "set to what gets triggered when resque-stuck-queue will detect the latest heartbeat is older than the trigger_timeout time setting.\n\tExample:\n\tResque::StuckQueue.config[:triggered_handler] = proc { |queue_name, lagtime| send_email('queue \#{queue_name} isnt working, aaah the daemons') }",
23-
:recovered_handler => "set to what gets triggered when resque-stuck-queue has triggered a problem, but then detects the queue went back down to functioning well again(it wont trigger again until it has recovered).\n\tExample:\n\tResque::StuckQueue.config[:recovered_handler] = proc { |queue_name, lagtime| send_email('phew, queue \#{queue_name} is ok') }",
24-
:heartbeat_interval => "set to how often to push the 'heartbeat' job which will refresh the latest working time.\n\tExample:\n\tResque::StuckQueue.config[:heartbeat_interval] = 5.minutes",
25-
:watcher_interval => "set to how often to check to see when the last time it worked was.\n\tExample:\n\tResque::StuckQueue.config[:watcher_interval] = 1.minute",
26-
:trigger_timeout => "set to how much of a resque work lag you are willing to accept before being notified. note: take the :watcher_interval setting into account when setting this timeout.\n\tExample:\n\tResque::StuckQueue.config[:trigger_timeout] = 9.minutes",
27-
:warn_interval => "optional: if set, it will continiously trigger/warn in spaces of this interval after first trigger. eg, as long as lagtime keeps on being above trigger_timeout/recover hasn't occured yet.",
28-
:redis => "set the Redis StuckQueue will use. Either a Redis or Redis::Namespace instance.",
29-
:heartbeat_key => "optional, name of keys to keep track of the last good resque heartbeat time",
30-
:triggered_key => "optional, name of keys to keep track of the last trigger time",
31-
:logger => "optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.",
32-
:queues => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is [:app]",
33-
:abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is true",
34-
:heartbeat_job => "optional, your own custom refreshing job. if you are using something other than resque",
35-
:enable_signals => "optional, allow resque::stuck's signal_handlers which do mostly nothing at this point. possible future plan: log info, reopen log file, etc.",
22+
:triggered_handler => "set to what gets triggered when resque-stuck-queue will detect the latest heartbeat is older than the trigger_timeout time setting.\n\tExample:\n\tResque::StuckQueue.config[:triggered_handler] = proc { |queue_name, lagtime| send_email('queue \#{queue_name} isnt working, aaah the daemons') }",
23+
:recovered_handler => "set to what gets triggered when resque-stuck-queue has triggered a problem, but then detects the queue went back down to functioning well again(it wont trigger again until it has recovered).\n\tExample:\n\tResque::StuckQueue.config[:recovered_handler] = proc { |queue_name, lagtime| send_email('phew, queue \#{queue_name} is ok') }",
24+
:heartbeat_interval => "set to how often to push the 'heartbeat' job which will refresh the latest working time.\n\tExample:\n\tResque::StuckQueue.config[:heartbeat_interval] = 5.minutes",
25+
:watcher_interval => "set to how often to check to see when the last time it worked was.\n\tExample:\n\tResque::StuckQueue.config[:watcher_interval] = 1.minute",
26+
:trigger_timeout => "set to how much of a resque work lag you are willing to accept before being notified. note: take the :watcher_interval setting into account when setting this timeout.\n\tExample:\n\tResque::StuckQueue.config[:trigger_timeout] = 9.minutes",
27+
:warn_interval => "optional: if set, it will continiously trigger/warn in spaces of this interval after first trigger. eg, as long as lagtime keeps on being above trigger_timeout/recover hasn't occured yet.",
28+
:redis => "set the Redis StuckQueue will use. Either a Redis or Redis::Namespace instance.",
29+
:heartbeat_key => "optional, name of keys to keep track of the last good resque heartbeat time",
30+
:triggered_key => "optional, name of keys to keep track of the last trigger time",
31+
:logger => "optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.",
32+
:queues => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is [:app]",
33+
:abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is true",
34+
:heartbeat_job => "optional, your own custom refreshing job. if you are using something other than resque",
35+
:enable_signals => "optional, allow resque::stuck's signal_handlers which do mostly nothing at this point. possible future plan: log info, reopen log file, etc.",
36+
:disconnect_recovery => "optional, continues running resque-stuck-queue even if there is an issue connecting to redis. Will continue looping and making attempts until connection is re-established. Default is false",
3637
}
3738

3839
OPTIONS = OPTIONS_DESCRIPTIONS.keys

0 commit comments

Comments
 (0)