resque_stuck_queue 0.5.1 → 0.5.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 +7 -7
- data/Gemfile +1 -0
- data/README.md +6 -2
- data/Rakefile +2 -1
- data/THOUGHTS +2 -0
- data/lib/resque_stuck_queue.rb +2 -5
- data/lib/resque_stuck_queue/version.rb +1 -1
- data/test/test_config.rb +12 -13
- metadata +71 -56
- data/lib/resque_stuck_queue/signals.rb +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e3173c9944a71c3baf91b7e3792619f44c414c09
|
4
|
+
data.tar.gz: 068a8ca0c8688b3ff2ed27c7eb382fb361277bb4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 75f2f2021dffa38b41909de2d26bcae9fc374e62a4b78eb8d2818d4a4295b5e248b9e52fddf500edc6b9bb11e5f9cfed9921479aa4869516362101a69a158a25
|
7
|
+
data.tar.gz: 6ca49f65b55a4a351bc54d1178e174384dc689f5997de168e9e1cadaefb9f78a93b50a7e9f091c0038a35181bfe85d628a40eecd3b6bbab12a2cc0e9e66fcd1c
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -30,6 +30,8 @@ After firing the proc, it will continue to monitor the queue, but won't call the
|
|
30
30
|
|
31
31
|
By calling the recovered proc, it will then complain again the next time the lag is found.
|
32
32
|
|
33
|
+
You can also configure it to periodically trigger unless of couse it's recovered/good again (see the `:warn_interval` below).
|
34
|
+
|
33
35
|
## Usage
|
34
36
|
|
35
37
|
Run this as a daemon somewhere alongside the app/in your setup. You'll need to configure it to your needs first:
|
@@ -44,6 +46,7 @@ require 'logger'
|
|
44
46
|
Resque::StuckQueue.config[:heartbeat_interval] = 10.seconds
|
45
47
|
Resque::StuckQueue.config[:watcher_interval] = 1.seconds
|
46
48
|
Resque::StuckQueue.config[:trigger_timeout] = 30.seconds # acceptable lagtime
|
49
|
+
Resque::StuckQueue.config[:warn_interval] = 5.minutes # keep on triggering periodically, default is only one trigger
|
47
50
|
|
48
51
|
# which queues to monitor
|
49
52
|
Resque::StuckQueue.config[:queues] = [:app, :custom_queue]
|
@@ -101,7 +104,6 @@ $ bundle exec rake --trace resque:stuck_queue # outdated god config - https://gi
|
|
101
104
|
Configuration settings are below. You'll most likely at the least want to tune `:triggered_handler`,`:heartbeat_interval` and `:trigger_timeout` settings.
|
102
105
|
|
103
106
|
<pre>
|
104
|
-
|
105
107
|
triggered_handler:
|
106
108
|
set to what gets triggered when resque-stuck-queue will detect the latest heartbeat is older than the trigger_timeout time setting.
|
107
109
|
Example:
|
@@ -127,6 +129,9 @@ trigger_timeout:
|
|
127
129
|
Example:
|
128
130
|
Resque::StuckQueue.config[:trigger_timeout] = 9.minutes
|
129
131
|
|
132
|
+
warn_interval:
|
133
|
+
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.
|
134
|
+
|
130
135
|
redis:
|
131
136
|
set the Redis StuckQueue will use. Either a Redis or Redis::Namespace instance.
|
132
137
|
|
@@ -150,7 +155,6 @@ heartbeat_job:
|
|
150
155
|
|
151
156
|
enable_signals:
|
152
157
|
optional, allow resque::stuck's signal_handlers which do mostly nothing at this point. possible future plan: log info, reopen log file, etc.
|
153
|
-
|
154
158
|
</pre>
|
155
159
|
|
156
160
|
To start it:
|
data/Rakefile
CHANGED
data/THOUGHTS
CHANGED
@@ -5,3 +5,5 @@ rm require resque?
|
|
5
5
|
|
6
6
|
refactor tests to have an around(:suite) to run with resque beforehand (no startup time) and just run test_integration.rb
|
7
7
|
(& compact dup tests etc)
|
8
|
+
|
9
|
+
don't continue to send heartbeat job if its alerting/stuck, it can just back the queue up (even if just marginally) more.
|
data/lib/resque_stuck_queue.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "resque_stuck_queue/version"
|
2
2
|
require "resque_stuck_queue/config"
|
3
3
|
require "resque_stuck_queue/heartbeat_job"
|
4
|
-
require "resque_stuck_queue/signals"
|
5
4
|
|
6
5
|
require 'redis-namespace'
|
7
6
|
|
@@ -77,13 +76,11 @@ module Resque
|
|
77
76
|
config.validate_required_keys!
|
78
77
|
config.freeze
|
79
78
|
|
80
|
-
Signals.enable!
|
81
|
-
|
82
79
|
log_starting_info
|
83
80
|
|
84
81
|
reset_keys
|
85
82
|
|
86
|
-
|
83
|
+
RedisClassy.redis = redis if RedisClassy.redis.nil?
|
87
84
|
|
88
85
|
pretty_process_name
|
89
86
|
|
@@ -174,7 +171,7 @@ module Resque
|
|
174
171
|
Thread.current.abort_on_exception = abort_on_exception
|
175
172
|
log_starting_thread(:watcher)
|
176
173
|
while @running
|
177
|
-
mutex =
|
174
|
+
mutex = RedisMutex.new(:resque_stuck_queue, :block => 0)
|
178
175
|
if mutex.lock
|
179
176
|
begin
|
180
177
|
queues.each do |queue_name|
|
data/test/test_config.rb
CHANGED
@@ -49,19 +49,18 @@ class TestConfig < Minitest::Test
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
end
|
52
|
+
#def test_can_have_signals
|
53
|
+
#puts "#{__method__}"
|
54
|
+
#begin
|
55
|
+
#assert_equal ENV['SIGUSR1'], nil
|
56
|
+
#Resque::StuckQueue.config[:enable_signals] = true
|
57
|
+
#start_and_stop_loops_after(1)
|
58
|
+
#Process.kill "SIGUSR1", Process.pid
|
59
|
+
#assert_equal ENV['SIGUSR1'], "done be had"
|
60
|
+
#rescue => e
|
61
|
+
#assert false, "should have succeeded with signal handlers: #{e.inspect}\n#{e.backtrace.join("\n")}"
|
62
|
+
#end
|
63
|
+
#end
|
65
64
|
|
66
65
|
end
|
67
66
|
|
metadata
CHANGED
@@ -1,64 +1,79 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque_stuck_queue
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
|
-
authors:
|
6
|
+
authors:
|
7
7
|
- Shai Rosenfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
15
14
|
name: redis-mutex
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: "0"
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
23
20
|
type: :runtime
|
24
|
-
version_requirements: *id001
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: redis-namespace
|
27
21
|
prerelease: false
|
28
|
-
|
29
|
-
requirements:
|
30
|
-
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redis-namespace
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
31
34
|
type: :runtime
|
32
|
-
version_requirements: *id003
|
33
|
-
- !ruby/object:Gem::Dependency
|
34
|
-
name: bundler
|
35
35
|
prerelease: false
|
36
|
-
|
37
|
-
requirements:
|
38
|
-
- -
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
41
48
|
type: :development
|
42
|
-
version_requirements: *id004
|
43
|
-
- !ruby/object:Gem::Dependency
|
44
|
-
name: rake
|
45
49
|
prerelease: false
|
46
|
-
|
47
|
-
requirements:
|
48
|
-
-
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
49
62
|
type: :development
|
50
|
-
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
51
69
|
description: where the wild things are. err, when resque gets stuck
|
52
|
-
email:
|
70
|
+
email:
|
53
71
|
- srosenfeld@engineyard.com
|
54
72
|
executables: []
|
55
|
-
|
56
73
|
extensions: []
|
57
|
-
|
58
74
|
extra_rdoc_files: []
|
59
|
-
|
60
|
-
|
61
|
-
- .gitignore
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
62
77
|
- Gemfile
|
63
78
|
- LICENSE.txt
|
64
79
|
- README.md
|
@@ -68,7 +83,6 @@ files:
|
|
68
83
|
- lib/resque_stuck_queue.rb
|
69
84
|
- lib/resque_stuck_queue/config.rb
|
70
85
|
- lib/resque_stuck_queue/heartbeat_job.rb
|
71
|
-
- lib/resque_stuck_queue/signals.rb
|
72
86
|
- lib/resque_stuck_queue/version.rb
|
73
87
|
- resque_stuck_queue.gemspec
|
74
88
|
- test/resque/set_redis_key.rb
|
@@ -82,29 +96,30 @@ files:
|
|
82
96
|
- test/test_set_custom_refresh_job.rb
|
83
97
|
- test/test_ver_2.rb
|
84
98
|
homepage: https://github.com/shaiguitar/resque_stuck_queue/
|
85
|
-
licenses:
|
99
|
+
licenses:
|
86
100
|
- MIT
|
87
101
|
metadata: {}
|
88
|
-
|
89
102
|
post_install_message:
|
90
103
|
rdoc_options: []
|
91
|
-
|
92
|
-
require_paths:
|
104
|
+
require_paths:
|
93
105
|
- lib
|
94
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
-
|
97
|
-
|
98
|
-
|
99
|
-
|
106
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '0'
|
100
116
|
requirements: []
|
101
|
-
|
102
117
|
rubyforge_project:
|
103
|
-
rubygems_version: 2.
|
118
|
+
rubygems_version: 2.4.5.1
|
104
119
|
signing_key:
|
105
120
|
specification_version: 4
|
106
121
|
summary: fire a handler when your queues are wonky
|
107
|
-
test_files:
|
122
|
+
test_files:
|
108
123
|
- test/resque/set_redis_key.rb
|
109
124
|
- test/test_collision.rb
|
110
125
|
- test/test_config.rb
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
module Resque
|
3
|
-
module StuckQueue
|
4
|
-
module Signals
|
5
|
-
extend self
|
6
|
-
|
7
|
-
def enable!
|
8
|
-
if Resque::StuckQueue.config[:enable_signals]
|
9
|
-
|
10
|
-
trap("SIGUSR1") do
|
11
|
-
ENV['SIGUSR1'] = "done be had"
|
12
|
-
Resque::StuckQueue.logger.info("Inspecting StuckQueue config: #{Resque::StuckQueue.config.inspect}")
|
13
|
-
Resque::StuckQueue.queues.each do |q| Resque::StuckQueue.log_watcher_info(q) end
|
14
|
-
Resque::StuckQueue.logger.info("¯\_(ツ)_/¯ ...")
|
15
|
-
end
|
16
|
-
|
17
|
-
# do something meaningful
|
18
|
-
#trap("SIGUSR2") do
|
19
|
-
# require 'pry'
|
20
|
-
# binding.pry
|
21
|
-
#end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|