resque-scheduler 2.4.0 → 2.5.0
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.
- data/.rubocop.yml +3 -3
- data/AUTHORS.md +1 -0
- data/HISTORY.md +5 -0
- data/README.md +1 -1
- data/lib/resque/scheduler.rb +5 -1
- data/lib/resque_scheduler/server.rb +51 -1
- data/lib/resque_scheduler/server/views/delayed.erb +9 -5
- data/lib/resque_scheduler/server/views/search.erb +72 -0
- data/lib/resque_scheduler/server/views/search_form.erb +8 -0
- data/lib/resque_scheduler/version.rb +1 -1
- data/test/resque-web_test.rb +31 -1
- data/test/test_helper.rb +4 -0
- metadata +10 -2
data/.rubocop.yml
CHANGED
@@ -18,7 +18,7 @@ CaseEquality:
|
|
18
18
|
Enabled: false
|
19
19
|
|
20
20
|
ClassLength:
|
21
|
-
Max:
|
21
|
+
Max: 303
|
22
22
|
|
23
23
|
ClassVars:
|
24
24
|
Enabled: false
|
@@ -33,7 +33,7 @@ CommentAnnotation:
|
|
33
33
|
Enabled: false
|
34
34
|
|
35
35
|
CyclomaticComplexity:
|
36
|
-
Max:
|
36
|
+
Max: 28
|
37
37
|
|
38
38
|
Documentation:
|
39
39
|
Enabled: false
|
@@ -69,7 +69,7 @@ MethodCallParentheses:
|
|
69
69
|
Enabled: false
|
70
70
|
|
71
71
|
MethodLength:
|
72
|
-
Max:
|
72
|
+
Max: 180
|
73
73
|
|
74
74
|
ModuleFunction:
|
75
75
|
Enabled: false
|
data/AUTHORS.md
CHANGED
data/HISTORY.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Resque Scheduler History / ChangeLog / Release Notes
|
2
2
|
|
3
|
+
## 2.5.0 (2014-02-09)
|
4
|
+
* Use `logger.error` when logging errors from `handle_errors`
|
5
|
+
* Added search feature to the Delayed tab in Resque Web
|
6
|
+
* Fix confusion with redis version requirements in `README.md`
|
7
|
+
|
3
8
|
## 2.4.0 (2014-01-14)
|
4
9
|
|
5
10
|
* Including optional env name in procline
|
data/README.md
CHANGED
@@ -12,7 +12,7 @@ that adds support for queueing items in the future.
|
|
12
12
|
|
13
13
|
This table explains the version requirements for redis
|
14
14
|
|
15
|
-
| resque-scheduler version | required redis version|
|
15
|
+
| resque-scheduler version | required redis gem version|
|
16
16
|
|:-------------------------|----------------------:|
|
17
17
|
| ~> 2.0 | >= 3.0.0 |
|
18
18
|
| >= 0.0.1 | ~> 1.3 |
|
data/lib/resque/scheduler.rb
CHANGED
@@ -276,7 +276,7 @@ module Resque
|
|
276
276
|
begin
|
277
277
|
yield
|
278
278
|
rescue Exception => e
|
279
|
-
|
279
|
+
log_error "#{e.class.name}: #{e.message}"
|
280
280
|
end
|
281
281
|
end
|
282
282
|
|
@@ -398,6 +398,10 @@ module Resque
|
|
398
398
|
logger.info { msg }
|
399
399
|
end
|
400
400
|
|
401
|
+
def log_error(msg)
|
402
|
+
logger.error { msg }
|
403
|
+
end
|
404
|
+
|
401
405
|
def log(msg)
|
402
406
|
logger.debug { msg }
|
403
407
|
end
|
@@ -9,13 +9,49 @@ module ResqueScheduler
|
|
9
9
|
base.class_eval do
|
10
10
|
helpers do
|
11
11
|
def format_time(t)
|
12
|
-
t.strftime(
|
12
|
+
t.strftime('%Y-%m-%d %H:%M:%S %z')
|
13
13
|
end
|
14
14
|
|
15
15
|
def queue_from_class_name(class_name)
|
16
16
|
Resque.queue_from_class(ResqueScheduler::Util.constantize(class_name))
|
17
17
|
end
|
18
18
|
|
19
|
+
def find_job(worker)
|
20
|
+
worker = worker.downcase
|
21
|
+
results = Array.new
|
22
|
+
|
23
|
+
# Check working jobs
|
24
|
+
working = Resque.working
|
25
|
+
working = [working] unless working.is_a?(Array)
|
26
|
+
work = working.select do |w|
|
27
|
+
w.job && w.job["payload"] && w.job['payload']['class'].downcase.include?(worker)
|
28
|
+
end
|
29
|
+
work.each do |w|
|
30
|
+
results += [w.job['payload'].merge({'queue' => w.job['queue'], 'where_at' => 'working'})]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Check delayed Jobs
|
34
|
+
dels = Array.new
|
35
|
+
Resque.delayed_queue_peek(0, Resque.delayed_queue_schedule_size).each do |d|
|
36
|
+
Resque.delayed_timestamp_peek(d, 0, Resque.delayed_timestamp_size(d)).each do |j|
|
37
|
+
dels << j.merge!({'timestamp' => d})
|
38
|
+
end
|
39
|
+
end
|
40
|
+
results += dels.select do |j|
|
41
|
+
j['class'].downcase.include?(worker) && j.merge!({'where_at' => 'delayed'})
|
42
|
+
end
|
43
|
+
|
44
|
+
# Check Queues
|
45
|
+
Resque.queues.each do |queue|
|
46
|
+
queued = Resque.peek(queue, 0, Resque.size(queue))
|
47
|
+
queued = [queued] unless queued.is_a?(Array)
|
48
|
+
results += queued.select do |j|
|
49
|
+
j['class'].downcase.include?(worker) && j.merge!({'queue' => queue, 'where_at' => 'queued'})
|
50
|
+
end
|
51
|
+
end
|
52
|
+
results
|
53
|
+
end
|
54
|
+
|
19
55
|
def schedule_interval(config)
|
20
56
|
if config['every']
|
21
57
|
schedule_interval_every(config['every'])
|
@@ -104,6 +140,12 @@ module ResqueScheduler
|
|
104
140
|
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed_schedules.erb'))
|
105
141
|
end
|
106
142
|
|
143
|
+
post "/delayed/search" do
|
144
|
+
# Is there a better way to specify alternate template locations with sinatra?
|
145
|
+
@jobs = find_job(params[:search])
|
146
|
+
erb File.read(File.join(File.dirname(__FILE__), 'server/views/search.erb'))
|
147
|
+
end
|
148
|
+
|
107
149
|
get "/delayed/:timestamp" do
|
108
150
|
# Is there a better way to specify alternate template locations with sinatra?
|
109
151
|
erb File.read(File.join(File.dirname(__FILE__), 'server/views/delayed_timestamp.erb'))
|
@@ -115,6 +157,14 @@ module ResqueScheduler
|
|
115
157
|
redirect u("/overview")
|
116
158
|
end
|
117
159
|
|
160
|
+
post "/delayed/cancel_now" do
|
161
|
+
klass = ResqueScheduler::Util.constantize params['klass']
|
162
|
+
timestamp = params['timestamp']
|
163
|
+
args = Resque.decode params['args']
|
164
|
+
Resque.remove_delayed_job_from_timestamp(timestamp, klass, *args)
|
165
|
+
redirect u("/delayed")
|
166
|
+
end
|
167
|
+
|
118
168
|
post "/delayed/clear" do
|
119
169
|
Resque.reset_delayed_queue
|
120
170
|
redirect u('delayed')
|
@@ -1,10 +1,7 @@
|
|
1
1
|
<h1>Delayed Jobs</h1>
|
2
2
|
<%- size = resque.delayed_queue_schedule_size %>
|
3
|
-
|
4
|
-
|
5
|
-
<input type='submit' name='' value='Clear Delayed Jobs' />
|
6
|
-
</form>
|
7
|
-
<% end %>
|
3
|
+
|
4
|
+
<%= erb File.read(File.join(File.dirname(__FILE__), 'server/views/search_form.erb')) %>
|
8
5
|
|
9
6
|
<p class='intro'>
|
10
7
|
This list below contains the timestamps for scheduled delayed jobs.
|
@@ -48,4 +45,11 @@
|
|
48
45
|
<% end %>
|
49
46
|
</table>
|
50
47
|
|
48
|
+
<% if size > 0 %>
|
49
|
+
<br>
|
50
|
+
<form method="POST" action="<%=u 'delayed/clear'%>" class='clear-delayed'>
|
51
|
+
<input type='submit' name='' value='Clear Delayed Jobs' />
|
52
|
+
</form>
|
53
|
+
<% end %>
|
54
|
+
|
51
55
|
<%= partial :next_more, :start => start, :size => size %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<h1>Search Results</h1>
|
2
|
+
<%= erb File.read(File.join(File.dirname(__FILE__), 'server/views/search_form.erb')) %>
|
3
|
+
<hr>
|
4
|
+
<% delayed = @jobs.select { |j| j['where_at'] == 'delayed' } %>
|
5
|
+
<h1>Delayed jobs</h1>
|
6
|
+
<table class='jobs'>
|
7
|
+
<tr>
|
8
|
+
<th></th>
|
9
|
+
<th></th>
|
10
|
+
<th>Timestamp</th>
|
11
|
+
<th>Class</th>
|
12
|
+
<th>Args</th>
|
13
|
+
</tr>
|
14
|
+
<% delayed.each do |job| %>
|
15
|
+
<tr>
|
16
|
+
<td>
|
17
|
+
<form action="<%= u "/delayed/queue_now" %>" method="post">
|
18
|
+
<input type="hidden" name="timestamp" value="<%= job['timestamp'].to_i %>">
|
19
|
+
<input type="submit" value="Queue now">
|
20
|
+
</form>
|
21
|
+
</td>
|
22
|
+
<td>
|
23
|
+
<form action="<%= u "/delayed/cancel_now" %>" method="post">
|
24
|
+
<input type="hidden" name="timestamp" value="<%= job['timestamp'].to_i %>">
|
25
|
+
<input type="hidden" name="klass" value="<%= job['class'] %>">
|
26
|
+
<input type="hidden" name="args" value="<%= Resque.encode job['args'] %>">
|
27
|
+
<input type="submit" value="Cancel Job">
|
28
|
+
</form>
|
29
|
+
</td>
|
30
|
+
<td class='args'><%= format_time(Time.at(job['timestamp'])) %></td>
|
31
|
+
<td class='class'><%= job['class'] %></td>
|
32
|
+
<td class='args'><%= h job['args'].inspect %></td>
|
33
|
+
</tr>
|
34
|
+
<% end %>
|
35
|
+
</table>
|
36
|
+
</h1>
|
37
|
+
|
38
|
+
<% queued = @jobs.select { |j| j['where_at'] == 'queued' } %>
|
39
|
+
<h1>Queued jobs</h1>
|
40
|
+
<table class='jobs'>
|
41
|
+
<tr>
|
42
|
+
<th>Queue</th>
|
43
|
+
<th>Class</th>
|
44
|
+
<th>Args</th>
|
45
|
+
</tr>
|
46
|
+
<% queued.each do |job| %>
|
47
|
+
<tr>
|
48
|
+
<td class='class'><%= job['queue'] %></td>
|
49
|
+
<td class='class'><%= job['class'] %></td>
|
50
|
+
<td class='args'><%= h job['args'].inspect %></td>
|
51
|
+
</tr>
|
52
|
+
<% end %>
|
53
|
+
</table>
|
54
|
+
|
55
|
+
<% working = @jobs.select { |j| j['where_at'] == 'working' } %>
|
56
|
+
<h1>Working jobs</h1>
|
57
|
+
<table class='jobs'>
|
58
|
+
<tr>
|
59
|
+
<th>Queue</th>
|
60
|
+
<th>Class</th>
|
61
|
+
<th>Args</th>
|
62
|
+
</tr>
|
63
|
+
<% working.each do |job| %>
|
64
|
+
<tr>
|
65
|
+
<td class='class'><%= job['queue'] %></td>
|
66
|
+
<td class='class'><%= job['class'] %></td>
|
67
|
+
<td class='args'><%= h job['args'].inspect %></td>
|
68
|
+
</tr>
|
69
|
+
<% end %>
|
70
|
+
</table>
|
71
|
+
|
72
|
+
|
data/test/resque-web_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
2
|
|
3
3
|
# Pull in the server test_helper from resque
|
4
4
|
require 'resque/server/test_helper.rb'
|
@@ -167,3 +167,33 @@ context "POST /schedule/requeue_with_params" do
|
|
167
167
|
assert last_response.ok?, last_response.errors
|
168
168
|
end
|
169
169
|
end
|
170
|
+
|
171
|
+
context "on POST to /delayed/search" do
|
172
|
+
setup do
|
173
|
+
t = Time.now + 60
|
174
|
+
Resque.enqueue_at(t, SomeIvarJob)
|
175
|
+
Resque.enqueue(SomeQuickJob)
|
176
|
+
end
|
177
|
+
|
178
|
+
test 'should find matching scheduled job' do
|
179
|
+
post "/delayed/search" , 'search' => 'ivar'
|
180
|
+
assert last_response.status == 200
|
181
|
+
assert last_response.body.include?('SomeIvarJob')
|
182
|
+
end
|
183
|
+
|
184
|
+
test 'should find matching queued job' do
|
185
|
+
post "/delayed/search" , 'search' => 'quick'
|
186
|
+
assert last_response.status == 200
|
187
|
+
assert last_response.body.include?('SomeQuickJob')
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context "on POST to /delayed/cancel_now" do
|
192
|
+
setup { post "/delayed/cancel_now" }
|
193
|
+
|
194
|
+
test 'redirects to overview' do
|
195
|
+
assert last_response.status == 302
|
196
|
+
assert last_response.header['Location'].include? '/delayed'
|
197
|
+
end
|
198
|
+
|
199
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-02-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -221,6 +221,8 @@ files:
|
|
221
221
|
- lib/resque_scheduler/server/views/delayed_timestamp.erb
|
222
222
|
- lib/resque_scheduler/server/views/requeue-params.erb
|
223
223
|
- lib/resque_scheduler/server/views/scheduler.erb
|
224
|
+
- lib/resque_scheduler/server/views/search.erb
|
225
|
+
- lib/resque_scheduler/server/views/search_form.erb
|
224
226
|
- lib/resque_scheduler/tasks.rb
|
225
227
|
- lib/resque_scheduler/util.rb
|
226
228
|
- lib/resque_scheduler/version.rb
|
@@ -252,12 +254,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
252
254
|
- - ! '>='
|
253
255
|
- !ruby/object:Gem::Version
|
254
256
|
version: '0'
|
257
|
+
segments:
|
258
|
+
- 0
|
259
|
+
hash: -949662411159458522
|
255
260
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
261
|
none: false
|
257
262
|
requirements:
|
258
263
|
- - ! '>='
|
259
264
|
- !ruby/object:Gem::Version
|
260
265
|
version: '0'
|
266
|
+
segments:
|
267
|
+
- 0
|
268
|
+
hash: -949662411159458522
|
261
269
|
requirements: []
|
262
270
|
rubyforge_project:
|
263
271
|
rubygems_version: 1.8.23
|