resque 1.23.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/HISTORY.md +271 -0
- data/README.markdown +454 -484
- data/Rakefile +4 -17
- data/bin/resque-web +10 -22
- data/lib/resque/data_store.rb +335 -0
- data/lib/resque/errors.rb +15 -1
- data/lib/resque/failure/airbrake.rb +32 -4
- data/lib/resque/failure/base.rb +16 -7
- data/lib/resque/failure/multiple.rb +26 -8
- data/lib/resque/failure/redis.rb +92 -15
- data/lib/resque/failure/redis_multi_queue.rb +104 -0
- data/lib/resque/failure.rb +62 -32
- data/lib/resque/helpers.rb +11 -57
- data/lib/resque/job.rb +79 -12
- data/lib/resque/log_formatters/quiet_formatter.rb +7 -0
- data/lib/resque/log_formatters/verbose_formatter.rb +7 -0
- data/lib/resque/log_formatters/very_verbose_formatter.rb +8 -0
- data/lib/resque/logging.rb +18 -0
- data/lib/resque/plugin.rb +22 -10
- data/lib/resque/railtie.rb +10 -0
- data/lib/resque/server/public/jquery-3.6.0.min.js +2 -0
- data/lib/resque/server/public/jquery.relatize_date.js +4 -4
- data/lib/resque/server/public/main.js +3 -0
- data/lib/resque/server/public/ranger.js +16 -8
- data/lib/resque/server/public/style.css +13 -8
- data/lib/resque/server/views/error.erb +1 -1
- data/lib/resque/server/views/failed.erb +27 -59
- data/lib/resque/server/views/failed_job.erb +50 -0
- data/lib/resque/server/views/failed_queues_overview.erb +24 -0
- data/lib/resque/server/views/job_class.erb +8 -0
- data/lib/resque/server/views/key_sets.erb +2 -4
- data/lib/resque/server/views/key_string.erb +1 -1
- data/lib/resque/server/views/layout.erb +7 -6
- data/lib/resque/server/views/next_more.erb +22 -10
- data/lib/resque/server/views/processing.erb +2 -0
- data/lib/resque/server/views/queues.erb +22 -13
- data/lib/resque/server/views/stats.erb +5 -5
- data/lib/resque/server/views/workers.erb +4 -4
- data/lib/resque/server/views/working.erb +10 -11
- data/lib/resque/server.rb +51 -108
- data/lib/resque/server_helper.rb +185 -0
- data/lib/resque/stat.rb +19 -7
- data/lib/resque/tasks.rb +26 -25
- data/lib/resque/thread_signal.rb +24 -0
- data/lib/resque/vendor/utf8_util.rb +2 -8
- data/lib/resque/version.rb +1 -1
- data/lib/resque/web_runner.rb +374 -0
- data/lib/resque/worker.rb +487 -163
- data/lib/resque.rb +332 -52
- data/lib/tasks/redis.rake +11 -11
- metadata +169 -149
- data/lib/resque/failure/hoptoad.rb +0 -33
- data/lib/resque/failure/thoughtbot.rb +0 -33
- data/lib/resque/server/public/jquery-1.3.2.min.js +0 -19
- data/lib/resque/server/test_helper.rb +0 -19
- data/lib/resque/vendor/utf8_util/utf8_util_18.rb +0 -91
- data/lib/resque/vendor/utf8_util/utf8_util_19.rb +0 -5
- data/test/airbrake_test.rb +0 -27
- data/test/hoptoad_test.rb +0 -26
- data/test/job_hooks_test.rb +0 -464
- data/test/job_plugins_test.rb +0 -230
- data/test/plugin_test.rb +0 -116
- data/test/redis-test-cluster.conf +0 -115
- data/test/redis-test.conf +0 -115
- data/test/resque-web_test.rb +0 -59
- data/test/resque_failure_redis_test.rb +0 -19
- data/test/resque_test.rb +0 -278
- data/test/test_helper.rb +0 -178
- data/test/worker_test.rb +0 -657
@@ -0,0 +1,24 @@
|
|
1
|
+
<table id="failed">
|
2
|
+
<tbody>
|
3
|
+
<tr class="total">
|
4
|
+
<td class='queue'>Total Failed</td>
|
5
|
+
<td class='center'><%= Resque::Failure.count %></td>
|
6
|
+
</tr>
|
7
|
+
|
8
|
+
<% Resque::Failure.queues.sort.each do |queue| %>
|
9
|
+
<tr>
|
10
|
+
<th><b class="queue-tag"><a href="<%= u "/failed/#{queue}" %>"><%= queue %></a></b></th>
|
11
|
+
<th style="width:75px;" class="center"><%= Resque::Failure.count(queue) %></th>
|
12
|
+
</tr>
|
13
|
+
|
14
|
+
<% failed_class_counts(queue).sort_by { |name,_| name }.each do |k, v| %>
|
15
|
+
<tr id="<%= k %>">
|
16
|
+
<td>
|
17
|
+
<a href="<%= u "/failed/#{queue}?class=#{k}" %>"><span class="failed failed_class"><%= k %></span></a>
|
18
|
+
</td>
|
19
|
+
<td style="text-align: center;" class="failed<%= (v.to_i > 1000) ? '_many' : '' %>"><%= v %></td>
|
20
|
+
</tr>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
23
|
+
</tbody>
|
24
|
+
</table>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<% if job['class'] == 'ActiveJob::QueueAdapters::ResqueAdapter::JobWrapper' %>
|
2
|
+
<code><%= job['args'].first['job_class'] %></code>
|
3
|
+
<small>
|
4
|
+
<a href="http://edgeguides.rubyonrails.org/active_job_basics.html" rel="noopener noreferrer" target="_blank">(via ActiveJob)</a>
|
5
|
+
</small>
|
6
|
+
<% else %>
|
7
|
+
<code><%= job['class'] %></code>
|
8
|
+
<% end %>
|
@@ -1,8 +1,6 @@
|
|
1
1
|
<% if key = params[:key] %>
|
2
2
|
|
3
|
-
<p class='sub'>
|
4
|
-
Showing <%= start = params[:start].to_i %> to <%= start + 20 %> of <b><%=size = redis_get_size(key) %></b>
|
5
|
-
</p>
|
3
|
+
<p class='sub'><%= page_entries_info start = params[:start].to_i, start + 20, size = redis_get_size(key) %></p>
|
6
4
|
|
7
5
|
<h1>Key "<%= key %>" is a <%= resque.redis.type key %></h1>
|
8
6
|
<table>
|
@@ -15,5 +13,5 @@
|
|
15
13
|
<% end %>
|
16
14
|
</table>
|
17
15
|
|
18
|
-
<%= partial :next_more, :start => start, :size => size %>
|
16
|
+
<%= partial :next_more, :start => start, :size => size, :per_page => 20 %>
|
19
17
|
<% end %>
|
@@ -2,12 +2,13 @@
|
|
2
2
|
<html lang="en">
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
|
-
<title>Resque
|
5
|
+
<title>Resque</title>
|
6
6
|
<link href="<%=u 'reset.css' %>" media="screen" rel="stylesheet" type="text/css">
|
7
7
|
<link href="<%=u 'style.css' %>" media="screen" rel="stylesheet" type="text/css">
|
8
|
-
<script src="<%=u 'jquery-
|
8
|
+
<script src="<%=u 'jquery-3.6.0.min.js' %>" type="text/javascript"></script>
|
9
9
|
<script src="<%=u 'jquery.relatize_date.js' %>" type="text/javascript"></script>
|
10
10
|
<script src="<%=u 'ranger.js' %>" type="text/javascript"></script>
|
11
|
+
<script src="<%=u 'main.js' %>" type="text/javascript"></script>
|
11
12
|
</head>
|
12
13
|
<body>
|
13
14
|
<div class="header">
|
@@ -23,7 +24,7 @@
|
|
23
24
|
<% end %>
|
24
25
|
</div>
|
25
26
|
|
26
|
-
<% if @subtabs %>
|
27
|
+
<% if defined?(@subtabs) && @subtabs %>
|
27
28
|
<ul class='subnav'>
|
28
29
|
<% for subtab in @subtabs %>
|
29
30
|
<li <%= class_if_current "#{current_section}/#{subtab}" %>><a href="<%= current_section %>/<%= subtab %>"><span><%= subtab %></span></a></li>
|
@@ -36,9 +37,9 @@
|
|
36
37
|
</div>
|
37
38
|
|
38
39
|
<div id="footer">
|
39
|
-
<p>Powered by <a href="http://github.com/
|
40
|
-
<p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%=Resque.redis_id%></p>
|
40
|
+
<p>Powered by <a href="http://github.com/resque/resque">Resque</a> v<%=Resque::VERSION%></p>
|
41
|
+
<p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%= h Resque.redis_id %></p>
|
41
42
|
</div>
|
42
43
|
|
43
44
|
</body>
|
44
|
-
</html>
|
45
|
+
</html>
|
@@ -1,10 +1,22 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
<%
|
1
|
+
<% # per_page was added in 1.23.1; gems which add to resque-server don't pass that variable along so it would crash %>
|
2
|
+
<% # without a default value %>
|
3
|
+
<% per_page ||= 20 %>
|
4
|
+
<%if start - per_page >= 0 || start + per_page <= size%>
|
5
|
+
<div class='pagination'>
|
6
|
+
<% if start - per_page >= 0 %>
|
7
|
+
<a href="<%= current_page %>?start=<%= start - per_page %>" class='less'>« Previous</a>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% (size / per_page.to_f).ceil.times do |page_num| %>
|
11
|
+
<% if start == page_num * per_page %>
|
12
|
+
<span><%= page_num + 1 %></span>
|
13
|
+
<% else %>
|
14
|
+
<a href="<%= current_page %>?start=<%= page_num * per_page %>"> <%= page_num + 1 %></a>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% if start + per_page < size %>
|
19
|
+
<a href="<%= current_page %>?start=<%= start + per_page %>" class='more'>Next »</a>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
<%end%>
|
@@ -1,20 +1,20 @@
|
|
1
1
|
<% @subtabs = resque.queues unless partial? || params[:id].nil? %>
|
2
2
|
|
3
|
-
<% if
|
3
|
+
<% if current_queue = params[:id] %>
|
4
4
|
|
5
|
-
<h1>Pending jobs on <span class='hl'><%=
|
6
|
-
<form method="POST" action="<%=u "/queues/#{
|
7
|
-
<input type='submit' name='' value='Remove Queue'
|
5
|
+
<h1>Pending jobs on <span class='hl'><%= h escape_html(current_queue) %></span></h1>
|
6
|
+
<form method="POST" action="<%=u "/queues/#{escape_html(current_queue)}/remove" %>" class='remove-queue'>
|
7
|
+
<input type='submit' name='' value='Remove Queue' class="confirmSubmission" />
|
8
8
|
</form>
|
9
|
-
<p class='sub'
|
9
|
+
<p class='sub'><%= page_entries_info start = params[:start].to_i, start + 19, size = resque.size(current_queue), 'job' %></p>
|
10
10
|
<table class='jobs'>
|
11
11
|
<tr>
|
12
12
|
<th>Class</th>
|
13
13
|
<th>Args</th>
|
14
14
|
</tr>
|
15
|
-
<% for job in (jobs = resque.peek(
|
15
|
+
<% for job in (jobs = resque.peek(current_queue, start, 20)) %>
|
16
16
|
<tr>
|
17
|
-
<td class='class'><%= job
|
17
|
+
<td class='class'><%= partial :job_class, :job => job %></td>
|
18
18
|
<td class='args'><%=h job['args'].inspect %></td>
|
19
19
|
</tr>
|
20
20
|
<% end %>
|
@@ -24,7 +24,7 @@
|
|
24
24
|
</tr>
|
25
25
|
<% end %>
|
26
26
|
</table>
|
27
|
-
<%= partial :next_more, :start => start, :size => size %>
|
27
|
+
<%= partial :next_more, :start => start, :size => size, :per_page => 20 %>
|
28
28
|
<% else %>
|
29
29
|
|
30
30
|
<h1 class='wi'>Queues</h1>
|
@@ -34,16 +34,25 @@
|
|
34
34
|
<th>Name</th>
|
35
35
|
<th>Jobs</th>
|
36
36
|
</tr>
|
37
|
-
<%
|
37
|
+
<% resque.queues.sort_by { |q| q.to_s }.each do |queue| %>
|
38
38
|
<tr>
|
39
39
|
<td class='queue'><a class="queue" href="<%= u "queues/#{queue}" %>"><%= queue %></a></td>
|
40
40
|
<td class='size'><%= resque.size queue %></td>
|
41
41
|
</tr>
|
42
42
|
<% end %>
|
43
|
-
|
44
|
-
|
45
|
-
<
|
46
|
-
|
43
|
+
<% if failed_multiple_queues? %>
|
44
|
+
<% Resque::Failure.queues.sort_by { |q| q.to_s }.each_with_index do |queue, i| %>
|
45
|
+
<tr class="<%= Resque::Failure.count(queue).zero? ? "failed" : "failure" %><%= " first_failure" if i.zero? %>">
|
46
|
+
<td class='queue failed'><a class="queue" href="<%= u "failed/#{queue}" %>"><%= queue %></a></td>
|
47
|
+
<td class='size'><%= Resque::Failure.count(queue) %></td>
|
48
|
+
</tr>
|
49
|
+
<% end %>
|
50
|
+
<% else %>
|
51
|
+
<tr class="<%= Resque::Failure.count.zero? ? "failed" : "failure" %>">
|
52
|
+
<td class='queue failed'><a class="queue" href="<%= u :failed %>">failed</a></td>
|
53
|
+
<td class='size'><%= Resque::Failure.count %></td>
|
54
|
+
</tr>
|
55
|
+
<% end %>
|
47
56
|
</table>
|
48
57
|
|
49
58
|
<% end %>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
<% elsif params[:id] == "resque" %>
|
8
8
|
|
9
|
-
<h1><%= resque %></h1>
|
9
|
+
<h1><%= h resque %></h1>
|
10
10
|
<table class='stats'>
|
11
11
|
<% for key, value in resque.info.to_a.sort_by { |i| i[0].to_s } %>
|
12
12
|
<tr>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
<%= key %>
|
15
15
|
</th>
|
16
16
|
<td>
|
17
|
-
<%= value %>
|
17
|
+
<%= h value %>
|
18
18
|
</td>
|
19
19
|
</tr>
|
20
20
|
<% end %>
|
@@ -22,9 +22,9 @@
|
|
22
22
|
|
23
23
|
<% elsif params[:id] == 'redis' %>
|
24
24
|
|
25
|
-
<h1><%= resque.redis_id %></h1>
|
25
|
+
<h1><%= h resque.redis_id %></h1>
|
26
26
|
<table class='stats'>
|
27
|
-
<% for key, value in resque.redis.info.to_a.sort_by { |i| i[0].to_s } %>
|
27
|
+
<% for key, value in resque.redis.redis.info.to_a.sort_by { |i| i[0].to_s } %>
|
28
28
|
<tr>
|
29
29
|
<th>
|
30
30
|
<%= key %>
|
@@ -38,7 +38,7 @@
|
|
38
38
|
|
39
39
|
<% elsif params[:id] == 'keys' %>
|
40
40
|
|
41
|
-
<h1>Keys owned by <%= resque %></h1>
|
41
|
+
<h1>Keys owned by <%= h resque.redis_id %></h1>
|
42
42
|
<p class='sub'>(All keys are actually prefixed with "<%= Resque.redis.namespace %>:")</p>
|
43
43
|
<table class='stats'>
|
44
44
|
<tr>
|
@@ -9,6 +9,7 @@
|
|
9
9
|
<th>Host</th>
|
10
10
|
<th>Pid</th>
|
11
11
|
<th>Started</th>
|
12
|
+
<th>Heartbeat</th>
|
12
13
|
<th>Queues</th>
|
13
14
|
<th>Processed</th>
|
14
15
|
<th>Failed</th>
|
@@ -21,14 +22,14 @@
|
|
21
22
|
<td><%= host %></td>
|
22
23
|
<td><%= pid %></td>
|
23
24
|
<td><span class="time"><%= worker.started %></span></td>
|
25
|
+
<td><span class="time"><%= worker.heartbeat %></span></td>
|
24
26
|
<td class='queues'><%= queues.split(',').map { |q| '<a class="queue-tag" href="' + u("/queues/#{q}") + '">' + q + '</a>'}.join('') %></td>
|
25
27
|
<td><%= worker.processed %></td>
|
26
28
|
<td><%= worker.failed %></td>
|
27
29
|
<td class='process'>
|
28
30
|
<% data = worker.processing || {} %>
|
29
31
|
<% if data['queue'] %>
|
30
|
-
|
31
|
-
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= data['run_at'] %></a></small>
|
32
|
+
<%= partial :processing, :worker => worker, :job => data %>
|
32
33
|
<% else %>
|
33
34
|
<span class='waiting'>Waiting for a job...</span>
|
34
35
|
<% end %>
|
@@ -68,8 +69,7 @@
|
|
68
69
|
<td class='process'>
|
69
70
|
<% data = worker.processing || {} %>
|
70
71
|
<% if data['queue'] %>
|
71
|
-
|
72
|
-
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= data['run_at'] %></a></small>
|
72
|
+
<%= partial :processing, :worker => worker, :job => data %>
|
73
73
|
<% else %>
|
74
74
|
<span class='waiting'>Waiting for a job...</span>
|
75
75
|
<% end %>
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<% if params[:id] && (
|
2
|
-
<h1><%=
|
1
|
+
<% if params[:id] && (current_worker = Resque::Worker.find(params[:id])) && (data = current_worker.job) %>
|
2
|
+
<h1><%= current_worker %>'s job</h1>
|
3
3
|
|
4
4
|
<table>
|
5
5
|
<tr>
|
@@ -12,16 +12,16 @@
|
|
12
12
|
</tr>
|
13
13
|
<tr>
|
14
14
|
<td><img src="<%=u 'working.png' %>" alt="working" title="working"></td>
|
15
|
-
<% host, pid, _ =
|
16
|
-
<td><a href="<%=u "/workers/#{
|
17
|
-
<% data = worker.job %>
|
15
|
+
<% host, pid, _ = current_worker.to_s.split(':') %>
|
16
|
+
<td><a href="<%=u "/workers/#{current_worker}" %>"><%= host %>:<%= pid %></a></td>
|
18
17
|
<% queue = data['queue'] %>
|
19
18
|
<td><a class="queue" href="<%=u "/queues/#{queue}" %>"><%= queue %></a></td>
|
20
19
|
<td><span class="time"><%= data['run_at'] %></span></td>
|
20
|
+
<% payload = data.key?('payload') ? data['payload'] : {} %>
|
21
21
|
<td>
|
22
|
-
<code><%=
|
22
|
+
<code><%= payload.key?('class') ? payload['class'] : "—" %></code>
|
23
23
|
</td>
|
24
|
-
<td><%=h
|
24
|
+
<td><pre><%=h payload.key?('args') ? show_args(payload['args']) : "—" %></pre></td>
|
25
25
|
</tr>
|
26
26
|
</table>
|
27
27
|
|
@@ -49,18 +49,17 @@
|
|
49
49
|
</tr>
|
50
50
|
<% end %>
|
51
51
|
|
52
|
-
<% worker_jobs.sort_by {|
|
52
|
+
<% worker_jobs.sort_by { |_w, j| j['run_at'] ? j['run_at'].to_s() : '' }.each do |worker, job| %>
|
53
53
|
<tr>
|
54
54
|
<td class='icon'><img src="<%=u state = worker.state %>.png" alt="<%= state %>" title="<%= state %>"></td>
|
55
|
-
<% host, pid,
|
55
|
+
<% host, pid, _queues = worker.to_s.split(':') %>
|
56
56
|
<td class='where'><a href="<%=u "/workers/#{worker}" %>"><%= host %>:<%= pid %></a></td>
|
57
57
|
<td class='queues queue'>
|
58
58
|
<a class="queue-tag" href="<%=u "/queues/#{job['queue']}" %>"><%= job['queue'] %></a>
|
59
59
|
</td>
|
60
60
|
<td class='process'>
|
61
61
|
<% if job['queue'] %>
|
62
|
-
|
63
|
-
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= job['run_at'] %></a></small>
|
62
|
+
<%= partial :processing, :worker => worker, :job => job %>
|
64
63
|
<% else %>
|
65
64
|
<span class='waiting'>Waiting for a job...</span>
|
66
65
|
<% end %>
|
data/lib/resque/server.rb
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'sinatra/base'
|
2
|
-
require 'erb'
|
2
|
+
require 'tilt/erb'
|
3
3
|
require 'resque'
|
4
|
+
require 'resque/server_helper'
|
4
5
|
require 'resque/version'
|
5
6
|
require 'time'
|
7
|
+
require 'yaml'
|
6
8
|
|
7
|
-
if defined? Encoding
|
9
|
+
if defined?(Encoding) && Encoding.default_external != Encoding::UTF_8
|
8
10
|
Encoding.default_external = Encoding::UTF_8
|
9
11
|
end
|
10
12
|
|
@@ -23,109 +25,7 @@ module Resque
|
|
23
25
|
set :static, true
|
24
26
|
|
25
27
|
helpers do
|
26
|
-
include
|
27
|
-
alias_method :h, :escape_html
|
28
|
-
|
29
|
-
def current_section
|
30
|
-
url_path request.path_info.sub('/','').split('/')[0].downcase
|
31
|
-
end
|
32
|
-
|
33
|
-
def current_page
|
34
|
-
url_path request.path_info.sub('/','')
|
35
|
-
end
|
36
|
-
|
37
|
-
def url_path(*path_parts)
|
38
|
-
[ path_prefix, path_parts ].join("/").squeeze('/')
|
39
|
-
end
|
40
|
-
alias_method :u, :url_path
|
41
|
-
|
42
|
-
def path_prefix
|
43
|
-
request.env['SCRIPT_NAME']
|
44
|
-
end
|
45
|
-
|
46
|
-
def class_if_current(path = '')
|
47
|
-
'class="current"' if current_page[0, path.size] == path
|
48
|
-
end
|
49
|
-
|
50
|
-
def tab(name)
|
51
|
-
dname = name.to_s.downcase
|
52
|
-
path = url_path(dname)
|
53
|
-
"<li #{class_if_current(path)}><a href='#{path}'>#{name}</a></li>"
|
54
|
-
end
|
55
|
-
|
56
|
-
def tabs
|
57
|
-
Resque::Server.tabs
|
58
|
-
end
|
59
|
-
|
60
|
-
def redis_get_size(key)
|
61
|
-
case Resque.redis.type(key)
|
62
|
-
when 'none'
|
63
|
-
[]
|
64
|
-
when 'list'
|
65
|
-
Resque.redis.llen(key)
|
66
|
-
when 'set'
|
67
|
-
Resque.redis.scard(key)
|
68
|
-
when 'string'
|
69
|
-
Resque.redis.get(key).length
|
70
|
-
when 'zset'
|
71
|
-
Resque.redis.zcard(key)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
def redis_get_value_as_array(key, start=0)
|
76
|
-
case Resque.redis.type(key)
|
77
|
-
when 'none'
|
78
|
-
[]
|
79
|
-
when 'list'
|
80
|
-
Resque.redis.lrange(key, start, start + 20)
|
81
|
-
when 'set'
|
82
|
-
Resque.redis.smembers(key)[start..(start + 20)]
|
83
|
-
when 'string'
|
84
|
-
[Resque.redis.get(key)]
|
85
|
-
when 'zset'
|
86
|
-
Resque.redis.zrange(key, start, start + 20)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
def show_args(args)
|
91
|
-
Array(args).map { |a| a.inspect }.join("\n")
|
92
|
-
end
|
93
|
-
|
94
|
-
def worker_hosts
|
95
|
-
@worker_hosts ||= worker_hosts!
|
96
|
-
end
|
97
|
-
|
98
|
-
def worker_hosts!
|
99
|
-
hosts = Hash.new { [] }
|
100
|
-
|
101
|
-
Resque.workers.each do |worker|
|
102
|
-
host, _ = worker.to_s.split(':')
|
103
|
-
hosts[host] += [worker.to_s]
|
104
|
-
end
|
105
|
-
|
106
|
-
hosts
|
107
|
-
end
|
108
|
-
|
109
|
-
def partial?
|
110
|
-
@partial
|
111
|
-
end
|
112
|
-
|
113
|
-
def partial(template, local_vars = {})
|
114
|
-
@partial = true
|
115
|
-
erb(template.to_sym, {:layout => false}, local_vars)
|
116
|
-
ensure
|
117
|
-
@partial = false
|
118
|
-
end
|
119
|
-
|
120
|
-
def poll
|
121
|
-
if @polling
|
122
|
-
text = "Last Updated: #{Time.now.strftime("%H:%M:%S")}"
|
123
|
-
else
|
124
|
-
text = "<a href='#{u(request.path_info)}.poll' rel='poll'>Live Poll</a>"
|
125
|
-
end
|
126
|
-
"<p class='poll'>#{text}</p>"
|
127
|
-
end
|
128
|
-
|
28
|
+
include Resque::ServerHelper
|
129
29
|
end
|
130
30
|
|
131
31
|
def show(page, layout = true)
|
@@ -181,18 +81,39 @@ module Resque
|
|
181
81
|
end
|
182
82
|
end
|
183
83
|
|
84
|
+
get "/failed/:queue" do
|
85
|
+
if Resque::Failure.url
|
86
|
+
redirect Resque::Failure.url
|
87
|
+
else
|
88
|
+
show :failed
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
184
92
|
post "/failed/clear" do
|
185
93
|
Resque::Failure.clear
|
186
94
|
redirect u('failed')
|
187
95
|
end
|
188
96
|
|
97
|
+
post "/failed/clear_retried" do
|
98
|
+
Resque::Failure.clear_retried
|
99
|
+
redirect u('failed')
|
100
|
+
end
|
101
|
+
|
102
|
+
post "/failed/:queue/clear" do
|
103
|
+
Resque::Failure.clear params[:queue]
|
104
|
+
redirect u('failed')
|
105
|
+
end
|
106
|
+
|
189
107
|
post "/failed/requeue/all" do
|
190
|
-
Resque::Failure.
|
191
|
-
Resque::Failure.requeue(num)
|
192
|
-
end
|
108
|
+
Resque::Failure.requeue_all
|
193
109
|
redirect u('failed')
|
194
110
|
end
|
195
111
|
|
112
|
+
post "/failed/:queue/requeue/all" do
|
113
|
+
Resque::Failure.requeue_queue Resque::Failure.job_queue_name(params[:queue])
|
114
|
+
redirect url_path("/failed/#{params[:queue]}")
|
115
|
+
end
|
116
|
+
|
196
117
|
get "/failed/requeue/:index/?" do
|
197
118
|
Resque::Failure.requeue(params[:index])
|
198
119
|
if request.xhr?
|
@@ -202,11 +123,25 @@ module Resque
|
|
202
123
|
end
|
203
124
|
end
|
204
125
|
|
126
|
+
get "/failed/:queue/requeue/:index/?" do
|
127
|
+
Resque::Failure.requeue(params[:index], params[:queue])
|
128
|
+
if request.xhr?
|
129
|
+
return Resque::Failure.all(params[:index],1,params[:queue])['retried_at']
|
130
|
+
else
|
131
|
+
redirect url_path("/failed/#{params[:queue]}")
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
205
135
|
get "/failed/remove/:index/?" do
|
206
136
|
Resque::Failure.remove(params[:index])
|
207
137
|
redirect u('failed')
|
208
138
|
end
|
209
139
|
|
140
|
+
get "/failed/:queue/remove/:index/?" do
|
141
|
+
Resque::Failure.remove(params[:index], params[:queue])
|
142
|
+
redirect url_path("/failed/#{params[:queue]}")
|
143
|
+
end
|
144
|
+
|
210
145
|
get "/stats/?" do
|
211
146
|
redirect url_path("/stats/resque")
|
212
147
|
end
|
@@ -244,5 +179,13 @@ module Resque
|
|
244
179
|
def self.tabs
|
245
180
|
@tabs ||= ["Overview", "Working", "Failed", "Queues", "Workers", "Stats"]
|
246
181
|
end
|
182
|
+
|
183
|
+
def self.url_prefix=(url_prefix)
|
184
|
+
@url_prefix = url_prefix
|
185
|
+
end
|
186
|
+
|
187
|
+
def self.url_prefix
|
188
|
+
(@url_prefix.nil? || @url_prefix.empty?) ? '' : @url_prefix + '/'
|
189
|
+
end
|
247
190
|
end
|
248
191
|
end
|