resque-scheduler 2.5.4 → 2.5.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque-scheduler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -0
- data/README.md +2 -2
- data/lib/resque/scheduler/lock/resilient.rb +9 -0
- data/lib/resque_scheduler/logger_builder.rb +7 -5
- data/lib/resque_scheduler/server.rb +5 -0
- data/lib/resque_scheduler/server/views/delayed.erb +5 -1
- data/lib/resque_scheduler/server/views/scheduler.erb +1 -1
- data/lib/resque_scheduler/version.rb +1 -1
- data/resque-scheduler.gemspec +1 -0
- data/test/resque-web_test.rb +12 -1
- data/test/scheduler_locking_test.rb +49 -0
- data/test/scheduler_setup_test.rb +5 -5
- data/test/test_helper.rb +6 -0
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62efe393e6b613cf1d08a9d757105c124976010d
|
4
|
+
data.tar.gz: 9e61be4df36fa45b2e46ce09b97d8460481bf814
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 031282aff18c1d4ed4b57b906190adcae00c303cfa50ef66cbe6823761da44180194e64f15d5e81474486092e71a86d24d258294092dc00b2da5f2a27bd26024
|
7
|
+
data.tar.gz: 310937e91fd414c72d95f5394e9dd38090a6e291ba94b78cbab470e5ca9dd92c8365853c0244460e0934cafbac43835fe97adcc0c6de63d4c3eecee5737dac48
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Resque Scheduler History / ChangeLog / Release Notes
|
2
2
|
|
3
|
+
## 2.5.5 (2014-02-27)
|
4
|
+
* Only showing link to job with args if job is present
|
5
|
+
* Only showing scheduled jobs that match current env or omit env
|
6
|
+
* Ensuring lock and acquire lua scripts are refreshed on timeout change
|
7
|
+
* Switch to using `mono_logger` instead of stdlib `logger`
|
8
|
+
|
3
9
|
## 2.5.4 (2014-02-17)
|
4
10
|
* Documentation updates
|
5
11
|
|
data/README.md
CHANGED
@@ -145,9 +145,9 @@ scheduled job must run (coerced with `Kernel#Float()`) (default `5`)
|
|
145
145
|
default `'text'`)
|
146
146
|
* `PIDFILE` - If non-empty, write process PID to file (default empty)
|
147
147
|
* `QUIET` or `MUTE` - Silence most output if non-empty (equivalent to
|
148
|
-
a level of `
|
148
|
+
a level of `MonoLogger::FATAL`, default `false`)
|
149
149
|
* `VERBOSE` - Maximize log verbosity if non-empty (equivalent to a level
|
150
|
-
of `
|
150
|
+
of `MonoLogger::DEBUG`, default `false`)
|
151
151
|
|
152
152
|
|
153
153
|
### Resque Pool integration
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# vim:fileencoding=utf-8
|
2
2
|
|
3
|
+
require 'mono_logger'
|
4
|
+
|
3
5
|
module ResqueScheduler
|
4
6
|
# Just builds a logger, with specified verbosity and destination.
|
5
7
|
# The simplest example:
|
@@ -26,9 +28,9 @@ module ResqueScheduler
|
|
26
28
|
@format = opts[:format] || 'text'
|
27
29
|
end
|
28
30
|
|
29
|
-
# Returns an instance of
|
31
|
+
# Returns an instance of MonoLogger
|
30
32
|
def build
|
31
|
-
logger =
|
33
|
+
logger = MonoLogger.new(@log_dev)
|
32
34
|
logger.level = level
|
33
35
|
logger.formatter = send(:"#{@format}_formatter")
|
34
36
|
logger
|
@@ -38,11 +40,11 @@ module ResqueScheduler
|
|
38
40
|
|
39
41
|
def level
|
40
42
|
if @verbose && !@muted
|
41
|
-
|
43
|
+
MonoLogger::DEBUG
|
42
44
|
elsif !@muted
|
43
|
-
|
45
|
+
MonoLogger::INFO
|
44
46
|
else
|
45
|
-
|
47
|
+
MonoLogger::FATAL
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
@@ -82,6 +82,11 @@ module ResqueScheduler
|
|
82
82
|
config['class']
|
83
83
|
end
|
84
84
|
end
|
85
|
+
|
86
|
+
def scheduled_in_this_env?(name)
|
87
|
+
return true if Resque.schedule[name]['rails_env'].nil?
|
88
|
+
Resque.schedule[name]['rails_env'] == Resque::Scheduler.env
|
89
|
+
end
|
85
90
|
end
|
86
91
|
|
87
92
|
get "/schedule" do
|
@@ -40,7 +40,11 @@
|
|
40
40
|
<% end %>
|
41
41
|
</td>
|
42
42
|
<td><%= h(job['args'].inspect) if job && delayed_timestamp_size == 1 %></td>
|
43
|
-
<td
|
43
|
+
<td>
|
44
|
+
<% if job %>
|
45
|
+
<a href="<%=u URI("/delayed/jobs/#{job['class']}?args=" + URI.encode(job['args'].to_json)) %>">All schedules</a>
|
46
|
+
<% end %>
|
47
|
+
</td>
|
44
48
|
</tr>
|
45
49
|
<% end %>
|
46
50
|
</table>
|
@@ -16,7 +16,7 @@
|
|
16
16
|
<th>Queue</th>
|
17
17
|
<th>Arguments</th>
|
18
18
|
</tr>
|
19
|
-
<% Resque.schedule.keys.sort.each do |name| %>
|
19
|
+
<% Resque.schedule.keys.sort.select { |n| scheduled_in_this_env?(n) }.each do |name| %>
|
20
20
|
<% config = Resque.schedule[name] %>
|
21
21
|
<tr>
|
22
22
|
<td style="padding-top: 12px; padding-bottom: 2px; width: 10px">
|
data/resque-scheduler.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency 'rubocop' unless RUBY_VERSION < '1.9'
|
30
30
|
spec.add_development_dependency 'simplecov' unless RUBY_VERSION < '1.9'
|
31
31
|
|
32
|
+
spec.add_runtime_dependency 'mono_logger', '~> 1.0'
|
32
33
|
spec.add_runtime_dependency 'redis', '~> 3.0.4'
|
33
34
|
spec.add_runtime_dependency 'resque', '~> 1.25.1'
|
34
35
|
spec.add_runtime_dependency 'rufus-scheduler', '~> 2.0.24'
|
data/test/resque-web_test.rb
CHANGED
@@ -11,7 +11,7 @@ end
|
|
11
11
|
|
12
12
|
context "on GET to /schedule with scheduled jobs" do
|
13
13
|
setup do
|
14
|
-
|
14
|
+
Resque::Scheduler.env = 'production'
|
15
15
|
Resque.schedule = {
|
16
16
|
'some_ivar_job' => {
|
17
17
|
'cron' => "* * * * *",
|
@@ -26,6 +26,13 @@ context "on GET to /schedule with scheduled jobs" do
|
|
26
26
|
'args' => {
|
27
27
|
'b' => 'blah'
|
28
28
|
}
|
29
|
+
},
|
30
|
+
'some_fancy_job' => {
|
31
|
+
'every' => ['1m'],
|
32
|
+
'queue' => 'fancy',
|
33
|
+
'class' => 'SomeFancyJob',
|
34
|
+
'args' => 'sparkles',
|
35
|
+
'rails_env' => 'fancy'
|
29
36
|
}
|
30
37
|
}
|
31
38
|
Resque::Scheduler.load_schedule!
|
@@ -37,6 +44,10 @@ context "on GET to /schedule with scheduled jobs" do
|
|
37
44
|
test 'see the scheduled job' do
|
38
45
|
assert last_response.body.include?('SomeIvarJob')
|
39
46
|
end
|
47
|
+
|
48
|
+
test 'excludes jobs for other envs' do
|
49
|
+
assert !last_response.body.include?('SomeFancyJob')
|
50
|
+
end
|
40
51
|
end
|
41
52
|
|
42
53
|
context "on GET to /delayed" do
|
@@ -238,5 +238,54 @@ context 'Resque::Scheduler::Lock::Resilient' do
|
|
238
238
|
|
239
239
|
assert Resque.redis.ttl(@lock.key) <= 10, "TTL should not have been updated"
|
240
240
|
end
|
241
|
+
|
242
|
+
test 'setting the lock timeout changes the key TTL if we hold it' do
|
243
|
+
@lock.acquire!
|
244
|
+
|
245
|
+
@lock.stubs(:locked?).returns(true)
|
246
|
+
@lock.timeout = 120
|
247
|
+
ttl = Resque.redis.ttl(@lock.key)
|
248
|
+
assert_send [ttl, :>, 100]
|
249
|
+
|
250
|
+
@lock.stubs(:locked?).returns(true)
|
251
|
+
@lock.timeout = 180
|
252
|
+
ttl = Resque.redis.ttl(@lock.key)
|
253
|
+
assert_send [ttl, :>, 120]
|
254
|
+
end
|
255
|
+
|
256
|
+
test 'setting lock timeout is a noop if not held' do
|
257
|
+
@lock.acquire!
|
258
|
+
@lock.timeout = 100
|
259
|
+
@lock.stubs(:locked?).returns(false)
|
260
|
+
@lock.timeout = 120
|
261
|
+
assert_equal 100, @lock.timeout
|
262
|
+
end
|
263
|
+
|
264
|
+
test 'setting lock timeout nils out lock script' do
|
265
|
+
@lock.acquire!
|
266
|
+
@lock.timeout = 100
|
267
|
+
assert_equal nil, @lock.instance_variable_get(:@locked_sha)
|
268
|
+
end
|
269
|
+
|
270
|
+
test 'setting lock timeout does not nil out lock script if not held' do
|
271
|
+
@lock.acquire!
|
272
|
+
@lock.locked?
|
273
|
+
@lock.stubs(:locked?).returns(false)
|
274
|
+
@lock.timeout = 100
|
275
|
+
assert_not_nil @lock.instance_variable_get(:@locked_sha)
|
276
|
+
end
|
277
|
+
|
278
|
+
test 'setting lock timeout nils out acquire script' do
|
279
|
+
@lock.acquire!
|
280
|
+
@lock.timeout = 100
|
281
|
+
assert_equal nil, @lock.instance_variable_get(:@acquire_sha)
|
282
|
+
end
|
283
|
+
|
284
|
+
test 'setting lock timeout does not nil out acquire script if not held' do
|
285
|
+
@lock.acquire!
|
286
|
+
@lock.stubs(:locked?).returns(false)
|
287
|
+
@lock.timeout = 100
|
288
|
+
assert_not_nil @lock.instance_variable_get(:@acquire_sha)
|
289
|
+
end
|
241
290
|
end
|
242
291
|
end
|
@@ -12,7 +12,7 @@ context "Resque::Scheduler" do
|
|
12
12
|
teardown { restore_devnull_logfile }
|
13
13
|
|
14
14
|
test 'set custom logger' do
|
15
|
-
custom_logger =
|
15
|
+
custom_logger = MonoLogger.new('/dev/null')
|
16
16
|
Resque::Scheduler.logger = custom_logger
|
17
17
|
assert_equal(custom_logger, Resque::Scheduler.logger)
|
18
18
|
end
|
@@ -62,11 +62,11 @@ context "Resque::Scheduler" do
|
|
62
62
|
end
|
63
63
|
|
64
64
|
test 'not verbose' do
|
65
|
-
assert Resque::Scheduler.logger.level >
|
65
|
+
assert Resque::Scheduler.logger.level > MonoLogger::DEBUG
|
66
66
|
end
|
67
67
|
|
68
68
|
test 'not muted' do
|
69
|
-
assert Resque::Scheduler.logger.level <
|
69
|
+
assert Resque::Scheduler.logger.level < MonoLogger::FATAL
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -84,12 +84,12 @@ context "Resque::Scheduler" do
|
|
84
84
|
|
85
85
|
test 'set verbosity' do
|
86
86
|
Resque::Scheduler.verbose = true
|
87
|
-
assert Resque::Scheduler.logger.level ==
|
87
|
+
assert Resque::Scheduler.logger.level == MonoLogger::DEBUG
|
88
88
|
end
|
89
89
|
|
90
90
|
test 'mute logger' do
|
91
91
|
Resque::Scheduler.mute = true
|
92
|
-
assert Resque::Scheduler.logger.level ==
|
92
|
+
assert Resque::Scheduler.logger.level == MonoLogger::FATAL
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben VandenBos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - '>='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mono_logger
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: redis
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -241,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
241
255
|
version: '0'
|
242
256
|
requirements: []
|
243
257
|
rubyforge_project:
|
244
|
-
rubygems_version: 2.0.
|
258
|
+
rubygems_version: 2.0.14
|
245
259
|
signing_key:
|
246
260
|
specification_version: 4
|
247
261
|
summary: Light weight job scheduling on top of Resque
|