resque_stuck_queue 0.3.9 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +78 -46
- data/lib/resque_stuck_queue.rb +13 -7
- data/lib/resque_stuck_queue/config.rb +14 -10
- data/lib/resque_stuck_queue/version.rb +1 -1
- data/test/test_collision.rb +2 -1
- data/test/test_config.rb +3 -1
- data/test/test_integration.rb +4 -3
- data/test/test_lagtime.rb +2 -1
- data/test/test_named_queues.rb +5 -4
- data/test/test_resque_2.rb +2 -1
- data/test/test_resque_stuck_queue.rb +2 -1
- data/test/test_set_custom_refresh_job.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
SHA512:
|
3
|
-
data.tar.gz: b49e05a7aa945e1d8e39001f5e27f59c6b05b4ecad5818418291c80db897b9ed34f6f5d56fd9514ef1c98d637300eb5db264a0ef5163cff952b81adcb7f8dae6
|
4
|
-
metadata.gz: 0c690deec48cc352654f9ffd3e69de75d5770eaff6d18bc96094594fa3f9100114fbee733ce37594ffab2999888260dc876da2fb699508138676be4d7c1f1269
|
5
2
|
SHA1:
|
6
|
-
data.tar.gz:
|
7
|
-
metadata.gz:
|
3
|
+
data.tar.gz: 4afb591b2c6fd8c3fc37a27dd92d54af07de3e2e
|
4
|
+
metadata.gz: 19702480a46ba718628bcb98c6f0eab1fa0c2261
|
5
|
+
SHA512:
|
6
|
+
data.tar.gz: b05278c44a84b631e5e43a1e1ba84f3d29971e075526cf16d926ed8dbb921b8399f3da4aa4a309b4f50e90c6722a5b8dbfdf1b0219c22153cc7e558e02377b6b
|
7
|
+
metadata.gz: 727b6ec883cf0fdec4a23a4235675309c7ea321704e204991eddfc311432e846392432799837a153d55429b8518ddd39936caca101d8541760bf80f8c7aa1d80
|
data/README.md
CHANGED
@@ -24,17 +24,76 @@ After firing the proc, it will continue to monitor the queue, but won't call the
|
|
24
24
|
|
25
25
|
By calling the recovered proc, it will then complain again the next time the lag is found.
|
26
26
|
|
27
|
-
##
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Run this as a daemon somewhere alongside the app/in your setup. You'll need to configure it to your needs first:
|
30
|
+
|
31
|
+
Put something like this in `config/initializers/resque-stuck-queue.rb`:
|
32
|
+
|
33
|
+
<pre>
|
34
|
+
require 'resque_stuck_queue' # or require 'resque/stuck_queue'
|
35
|
+
require 'logger'
|
36
|
+
|
37
|
+
# change to decent values that make sense for you
|
38
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 10.seconds
|
39
|
+
Resque::StuckQueue.config[:trigger_timeout] = 30.seconds
|
40
|
+
|
41
|
+
# create a sync/unbuffered log
|
42
|
+
logpath = Rails.root.join('log', 'resque_stuck_queue.log')
|
43
|
+
logfile = File.open(logpath, "a")
|
44
|
+
logfile.sync = true
|
45
|
+
logger = Logger.new(logfile)
|
46
|
+
logger.formatter = Logger::Formatter.new
|
47
|
+
Resque::StuckQueue.config[:logger] = logger
|
48
|
+
|
49
|
+
Resque::StuckQueue.config[:redis] = YOUR_REDIS
|
50
|
+
|
51
|
+
# which queues to monitor
|
52
|
+
Resque::StuckQueue.config[:queues] = [:app, :custom_queue]
|
53
|
+
|
54
|
+
# handler for when a resque queue is being problematic
|
55
|
+
Resque::StuckQueue.config[:triggered_handler] = proc { |bad_queue, lagtime|
|
56
|
+
msg = "[BAD] AWSM #{Rails.env}'s Resque #{bad_queue} queue lagging job execution by #{lagtime} seconds."
|
57
|
+
send_email(msg)
|
58
|
+
}
|
59
|
+
|
60
|
+
# handler for when a resque queue recovers
|
61
|
+
Resque::StuckQueue.config[:recovered_handler] = proc { |good_queue, lagtime|
|
62
|
+
msg = "[GOOD] AWSM #{Rails.env}'s Resque #{good_queue} queue lagging job execution by #{lagtime} seconds."
|
63
|
+
send_email(msg)
|
64
|
+
}
|
65
|
+
|
66
|
+
</pre>
|
28
67
|
|
29
|
-
|
68
|
+
Then create a task to run it as a daemon (similar to how the resque rake job is implemented):
|
30
69
|
|
31
70
|
<pre>
|
32
|
-
|
71
|
+
|
72
|
+
# put this in lib/tasks/resque_stuck_queue.rb
|
73
|
+
|
74
|
+
namespace :resque do
|
75
|
+
desc "Start a Resque-stuck daemon"
|
76
|
+
# :environment dep task should load the config via the initializer
|
77
|
+
task :stuck_queue => :environment do
|
78
|
+
Resque::StuckQueue.start
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
33
83
|
</pre>
|
34
84
|
|
35
|
-
|
85
|
+
then run it via god, monit or whatever:
|
36
86
|
|
37
87
|
<pre>
|
88
|
+
$ bundle exec rake --trace resque:stuck_queue # outdated god config - https://gist.github.com/shaiguitar/298935953d91faa6bd4e
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
## Configuration Options
|
92
|
+
|
93
|
+
Configuration settings are below. You'll most likely at the least want to tune `:triggered_handler`,`:heartbeat_interval` and `:trigger_timeout` settings.
|
94
|
+
|
95
|
+
<pre>
|
96
|
+
|
38
97
|
triggered_handler:
|
39
98
|
set to what gets triggered when resque-stuck-queue will detect the latest heartbeat is older than the trigger_timeout time setting.
|
40
99
|
Example:
|
@@ -45,15 +104,20 @@ recovered_handler:
|
|
45
104
|
Example:
|
46
105
|
Resque::StuckQueue.config[:recovered_handler] = proc { |queue_name, lagtime| send_email('phew, queue #{queue_name} is ok') }
|
47
106
|
|
48
|
-
|
49
|
-
set to how often to push
|
107
|
+
heartbeat_interval:
|
108
|
+
set to how often to push the 'heartbeat' job which will refresh the latest working time.
|
109
|
+
Example:
|
110
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 5.minutes
|
111
|
+
|
112
|
+
watcher_interval:
|
113
|
+
set to how often to check to see when the last time it worked was.
|
50
114
|
Example:
|
51
|
-
Resque::StuckQueue.config[:
|
115
|
+
Resque::StuckQueue.config[:watcher_interval] = 1.minute
|
52
116
|
|
53
117
|
trigger_timeout:
|
54
|
-
set to how much of a resque work lag you are willing to accept before being notified. note: take the :
|
118
|
+
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.
|
55
119
|
Example:
|
56
|
-
Resque::StuckQueue.config[:trigger_timeout] =
|
120
|
+
Resque::StuckQueue.config[:trigger_timeout] = 9.minutes
|
57
121
|
|
58
122
|
redis:
|
59
123
|
set the Redis StuckQueue will use. Either a Redis or Redis::Namespace instance.
|
@@ -68,13 +132,17 @@ logger:
|
|
68
132
|
optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.
|
69
133
|
|
70
134
|
queues:
|
71
|
-
optional, monitor specific queues you want to send a heartbeat/monitor to. default is :app
|
135
|
+
optional, monitor specific queues you want to send a heartbeat/monitor to. default is [:app]
|
72
136
|
|
73
137
|
abort_on_exception:
|
74
138
|
optional, if you want the resque-stuck-queue threads to explicitly raise, default is false
|
75
139
|
|
76
140
|
heartbeat_job:
|
77
141
|
optional, your own custom refreshing job. if you are using something other than resque
|
142
|
+
|
143
|
+
enable_signals:
|
144
|
+
optional, allow resque::stuck's signal_handlers which do mostly nothing at this point.
|
145
|
+
|
78
146
|
</pre>
|
79
147
|
|
80
148
|
To start it:
|
@@ -91,42 +159,6 @@ Resque::StuckQueue.stop # this will block until the threads end
|
|
91
159
|
Resque::StuckQueue.force_stop! # force kill those threads and let's move on
|
92
160
|
</pre>
|
93
161
|
|
94
|
-
## Deployment/Integration
|
95
|
-
|
96
|
-
* Include this in the app in a config initializer of some sort.
|
97
|
-
|
98
|
-
Note though, the resque-stuck threads will live alongside the app server process so you will need to explicitely handle `start` _and_ `stop`. If you're deployed in a forking-server environment and the whatever process has this does not get restarted the threads will keep on going indefinitely.
|
99
|
-
|
100
|
-
* Run this as a daemon somewhere alongside the app/in your setup.
|
101
|
-
|
102
|
-
Contrived example:
|
103
|
-
|
104
|
-
<pre>
|
105
|
-
|
106
|
-
# put this in lib/tasks/resque_stuck_queue.rb
|
107
|
-
|
108
|
-
require 'resque_stuck_queue' # or require 'resque/stuck_queue'
|
109
|
-
|
110
|
-
namespace :resque do
|
111
|
-
desc "Start a Resque-stuck daemon"
|
112
|
-
task :stuck_queue do
|
113
|
-
|
114
|
-
Resque::StuckQueue.config[:heartbeat] = 10.minutes
|
115
|
-
Resque::StuckQueue.config[:trigger_timeout] = 1.hour
|
116
|
-
Resque::StuckQueue.config[:triggered_handler] = proc { |queue_name| $stderr.puts("resque queue #{queue_name} wonky!") }
|
117
|
-
|
118
|
-
Resque::StuckQueue.start # blocking operation, daemon running
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
# then:
|
123
|
-
|
124
|
-
$ bundle exec rake --trace resque:stuck_queue
|
125
|
-
|
126
|
-
# you can run this under god for example @ https://gist.github.com/shaiguitar/298935953d91faa6bd4e
|
127
|
-
|
128
|
-
</pre>
|
129
|
-
|
130
162
|
## Sidekiq/Other redis-based job queues
|
131
163
|
|
132
164
|
If you have trouble with other queues you can use this lib by setting your own custom refresh job (aka, the job that refreshes your queue specific heartbeat_key). The one thing you need to take care of is ensure whatever and however you enque your own custom job, it sets the heartbeat_key to Time.now:
|
data/lib/resque_stuck_queue.rb
CHANGED
@@ -134,7 +134,7 @@ module Resque
|
|
134
134
|
# ensure that jobs get executed and the time is updated!
|
135
135
|
logger.info("Sending heartbeat jobs")
|
136
136
|
enqueue_jobs
|
137
|
-
wait_for_it
|
137
|
+
wait_for_it(:heartbeat_interval)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
end
|
@@ -155,13 +155,13 @@ module Resque
|
|
155
155
|
def setup_watcher_thread
|
156
156
|
@threads << Thread.new do
|
157
157
|
Thread.current.abort_on_exception = config[:abort_on_exception]
|
158
|
-
logger.info("Starting
|
158
|
+
logger.info("Starting watcher thread")
|
159
159
|
while @running
|
160
160
|
mutex = Redis::Mutex.new('resque_stuck_queue_lock', block: 0)
|
161
161
|
if mutex.lock
|
162
162
|
begin
|
163
163
|
queues.each do |queue_name|
|
164
|
-
|
164
|
+
log_watcher_info(queue_name)
|
165
165
|
if should_trigger?(queue_name)
|
166
166
|
trigger_handler(queue_name, :triggered)
|
167
167
|
elsif should_recover?(queue_name)
|
@@ -172,7 +172,7 @@ module Resque
|
|
172
172
|
mutex.unlock
|
173
173
|
end
|
174
174
|
end
|
175
|
-
wait_for_it
|
175
|
+
wait_for_it(:watcher_interval)
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -248,7 +248,7 @@ module Resque
|
|
248
248
|
logger.info("Starting StuckQueue with config: #{self.config.inspect}")
|
249
249
|
end
|
250
250
|
|
251
|
-
def
|
251
|
+
def log_watcher_info(queue_name)
|
252
252
|
logger.info("Lag time for #{queue_name} is #{lag_time(queue_name).inspect} seconds.")
|
253
253
|
if triggered_ago = last_triggered(queue_name)
|
254
254
|
logger.info("Last triggered for #{queue_name} is #{triggered_ago.inspect} seconds.")
|
@@ -262,8 +262,14 @@ module Resque
|
|
262
262
|
redis.get(keyname)
|
263
263
|
end
|
264
264
|
|
265
|
-
def wait_for_it
|
266
|
-
|
265
|
+
def wait_for_it(type)
|
266
|
+
if type == :heartbeat_interval
|
267
|
+
sleep config[:heartbeat_interval] || HEARTBEAT_INTERVAL
|
268
|
+
elsif type == :watcher_interval
|
269
|
+
sleep config[:watcher_interval] || WATCHER_INTERVAL
|
270
|
+
else
|
271
|
+
raise 'Must sleep for :watcher_interval interval or :heartbeat_interval interval!'
|
272
|
+
end
|
267
273
|
end
|
268
274
|
|
269
275
|
def max_wait_time
|
@@ -3,31 +3,35 @@ module Resque
|
|
3
3
|
|
4
4
|
require 'logger'
|
5
5
|
# defaults
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
TRIGGER_TIMEOUT =
|
10
|
-
|
6
|
+
HEARTBEAT_INTERVAL = 5 * 60 # send heartbeat job every 5 minutes
|
7
|
+
WATCHER_INTERVAL = 5 # check key is udpated every 5 seconds.
|
8
|
+
|
9
|
+
TRIGGER_TIMEOUT = 60 * 60 # warn/trigger after an hour of lagtime.
|
10
|
+
|
11
11
|
# must be called by convention: type_handler
|
12
12
|
TRIGGERED_HANDLER = proc { |queue_name, lag| Resque::StuckQueue::LOGGER.info("Shit gone bad with them queues...on #{queue_name}. Lag time is #{lag}") }
|
13
13
|
RECOVERED_HANDLER = proc { |queue_name, lag| Resque::StuckQueue::LOGGER.info("recovered queue phew #{queue_name}. Lag time is #{lag}") }
|
14
14
|
|
15
|
+
LOGGER = Logger.new($stdout)
|
16
|
+
HEARTBEAT_KEY = "resque-stuck-queue"
|
17
|
+
TRIGGERED_KEY = "resque-stuck-queue-last-triggered"
|
18
|
+
|
15
19
|
class Config < Hash
|
16
20
|
|
17
21
|
OPTIONS_DESCRIPTIONS = {
|
18
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') }",
|
19
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') }",
|
20
|
-
:
|
21
|
-
:
|
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",
|
22
27
|
:redis => "set the Redis StuckQueue will use. Either a Redis or Redis::Namespace instance.",
|
23
|
-
|
24
28
|
:heartbeat_key => "optional, name of keys to keep track of the last good resque heartbeat time",
|
25
29
|
:triggered_key => "optional, name of keys to keep track of the last trigger time",
|
26
30
|
:logger => "optional, pass a Logger. Default a ruby logger will be instantiated. Needs to respond to that interface.",
|
27
|
-
:queues => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is :app",
|
31
|
+
:queues => "optional, monitor specific queues you want to send a heartbeat/monitor to. default is [:app]",
|
28
32
|
:abort_on_exception => "optional, if you want the resque-stuck-queue threads to explicitly raise, default is false",
|
29
33
|
:heartbeat_job => "optional, your own custom refreshing job. if you are using something other than resque",
|
30
|
-
:enable_signals => "optional, allow resque::stuck's signal_handlers",
|
34
|
+
:enable_signals => "optional, allow resque::stuck's signal_handlers which do mostly nothing at this point.",
|
31
35
|
}
|
32
36
|
|
33
37
|
OPTIONS = OPTIONS_DESCRIPTIONS.keys
|
data/test/test_collision.rb
CHANGED
@@ -6,6 +6,7 @@ class TestCollision < Minitest::Test
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
Resque::StuckQueue.config[:redis] = Redis.new
|
9
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
9
10
|
Resque::StuckQueue.redis.flushall
|
10
11
|
end
|
11
12
|
|
@@ -36,7 +37,7 @@ class TestCollision < Minitest::Test
|
|
36
37
|
private
|
37
38
|
|
38
39
|
def run_resque_stuck_daemon
|
39
|
-
Resque::StuckQueue.config[:
|
40
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
40
41
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
41
42
|
Resque::StuckQueue.config[:trigger_timeout] = 3
|
42
43
|
Resque::StuckQueue.config[:triggered_handler] = proc { Resque::StuckQueue.redis.incr("test-incr-key") }
|
data/test/test_config.rb
CHANGED
@@ -5,8 +5,9 @@ class TestConfig < Minitest::Test
|
|
5
5
|
include TestHelper
|
6
6
|
|
7
7
|
def setup
|
8
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
8
9
|
Resque::StuckQueue.config[:trigger_timeout] = 1
|
9
|
-
Resque::StuckQueue.config[:
|
10
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
10
11
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
11
12
|
Resque::StuckQueue.config[:redis] = Redis.new
|
12
13
|
end
|
@@ -48,6 +49,7 @@ class TestConfig < Minitest::Test
|
|
48
49
|
end
|
49
50
|
end
|
50
51
|
|
52
|
+
# FIXME
|
51
53
|
def test_can_have_signals
|
52
54
|
puts "#{__method__}"
|
53
55
|
begin
|
data/test/test_integration.rb
CHANGED
@@ -39,6 +39,7 @@ class TestIntegration < Minitest::Test
|
|
39
39
|
def setup
|
40
40
|
Resque::StuckQueue.config[:redis] = Redis.new
|
41
41
|
Resque::StuckQueue.redis.flushall
|
42
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
42
43
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
43
44
|
self.class.run_resque_before_all
|
44
45
|
self.class.tests_ran += 1
|
@@ -57,7 +58,7 @@ class TestIntegration < Minitest::Test
|
|
57
58
|
|
58
59
|
with_no_resque_failures do
|
59
60
|
Resque::StuckQueue.config[:trigger_timeout] = 10
|
60
|
-
Resque::StuckQueue.config[:
|
61
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
61
62
|
Resque::StuckQueue.config[:redis] = Redis.new
|
62
63
|
|
63
64
|
@triggered = false
|
@@ -73,7 +74,7 @@ class TestIntegration < Minitest::Test
|
|
73
74
|
|
74
75
|
with_no_resque_failures do
|
75
76
|
Resque::StuckQueue.config[:trigger_timeout] = 0
|
76
|
-
Resque::StuckQueue.config[:
|
77
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
77
78
|
Resque::StuckQueue.config[:redis] = Redis.new
|
78
79
|
|
79
80
|
@triggered = false
|
@@ -89,7 +90,7 @@ class TestIntegration < Minitest::Test
|
|
89
90
|
|
90
91
|
with_no_resque_failures do
|
91
92
|
Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
|
92
|
-
Resque::StuckQueue.config[:
|
93
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
93
94
|
Resque::StuckQueue.config[:redis] = Redis.new
|
94
95
|
|
95
96
|
begin
|
data/test/test_lagtime.rb
CHANGED
@@ -15,11 +15,12 @@ class TestLagTime < Minitest::Test
|
|
15
15
|
Resque::StuckQueue.config[:redis] = Redis.new
|
16
16
|
Resque::StuckQueue.redis.flushall
|
17
17
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
18
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
18
19
|
end
|
19
20
|
|
20
21
|
def test_triggers_handler_with_lagtime
|
21
22
|
Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
|
22
|
-
Resque::StuckQueue.config[:
|
23
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
23
24
|
@lagtime = 0
|
24
25
|
Resque::StuckQueue.config[:triggered_handler] = proc { |queue_name, lagtime| @lagtime = lagtime }
|
25
26
|
start_and_stop_loops_after(5)
|
data/test/test_named_queues.rb
CHANGED
@@ -6,9 +6,10 @@ class TestNamedQueues < Minitest::Test
|
|
6
6
|
|
7
7
|
def setup
|
8
8
|
Resque::StuckQueue.config[:trigger_timeout] = 1
|
9
|
-
Resque::StuckQueue.config[:
|
9
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
10
10
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
11
11
|
Resque::StuckQueue.config[:redis] = Redis.new
|
12
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
12
13
|
Resque::StuckQueue.redis.flushall
|
13
14
|
end
|
14
15
|
|
@@ -34,7 +35,7 @@ class TestNamedQueues < Minitest::Test
|
|
34
35
|
def test_resque_enqueues_a_job_with_resqueue_running_but_on_that_queue_does_trigger
|
35
36
|
puts "#{__method__}"
|
36
37
|
Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
|
37
|
-
Resque::StuckQueue.config[:
|
38
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
38
39
|
Resque::StuckQueue.config[:queues] = [:custom_queue_name]
|
39
40
|
@triggered = false
|
40
41
|
Resque::StuckQueue.config[:triggered_handler] = proc { |queue_name| @triggered = queue_name }
|
@@ -51,7 +52,7 @@ class TestNamedQueues < Minitest::Test
|
|
51
52
|
def test_resque_enqueues_a_job_correct_queue_does_not_trigger
|
52
53
|
puts "#{__method__}"
|
53
54
|
Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
|
54
|
-
Resque::StuckQueue.config[:
|
55
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
55
56
|
Resque::StuckQueue.config[:queues] = [:custom_queue_name, :diff_one]
|
56
57
|
assert Resque::StuckQueue.heartbeat_keys.include?("custom_queue_name:resque-stuck-queue"), 'has global keys'
|
57
58
|
@triggered = false
|
@@ -69,7 +70,7 @@ class TestNamedQueues < Minitest::Test
|
|
69
70
|
puts "#{__method__}"
|
70
71
|
|
71
72
|
Resque::StuckQueue.config[:trigger_timeout] = 2
|
72
|
-
Resque::StuckQueue.config[:
|
73
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
73
74
|
Resque::StuckQueue.config[:queues] = [:app]
|
74
75
|
|
75
76
|
@triggered = 0
|
data/test/test_resque_2.rb
CHANGED
@@ -24,7 +24,8 @@ if !ENV['RESQUE_2'].nil?
|
|
24
24
|
|
25
25
|
Resque::StuckQueue.config[:redis] = Redis.new
|
26
26
|
|
27
|
-
Resque::StuckQueue.config[:
|
27
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
28
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
28
29
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
29
30
|
Resque::StuckQueue.config[:trigger_timeout] = 5
|
30
31
|
Resque::StuckQueue.config[:logger] = Logger.new($stdout)
|
@@ -13,8 +13,9 @@ class TestResqueStuckQueue < Minitest::Test
|
|
13
13
|
puts "#{__method__}"
|
14
14
|
# clean previous test runs
|
15
15
|
Resque::StuckQueue.config[:redis] = Redis.new
|
16
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
16
17
|
Resque::StuckQueue.redis.flushall
|
17
|
-
Resque::StuckQueue.config[:
|
18
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1 # seconds
|
18
19
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
19
20
|
end
|
20
21
|
|
@@ -7,7 +7,8 @@ class TestYourOwnRefreshJob < Minitest::Test
|
|
7
7
|
def setup
|
8
8
|
Resque::StuckQueue.reset!
|
9
9
|
Resque::StuckQueue.config[:trigger_timeout] = 1
|
10
|
-
Resque::StuckQueue.config[:
|
10
|
+
Resque::StuckQueue.config[:heartbeat_interval] = 1
|
11
|
+
Resque::StuckQueue.config[:watcher_interval] = 1
|
11
12
|
Resque::StuckQueue.config[:abort_on_exception] = true
|
12
13
|
Resque::StuckQueue.config[:heartbeat_job] = nil
|
13
14
|
Resque::StuckQueue.config[:redis] = Redis.new
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_stuck_queue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shai Rosenfeld
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2014-02-
|
12
|
+
date: 2014-02-02 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redis-mutex
|