resqueue 1.0.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 +488 -0
- data/LICENSE +20 -0
- data/README.markdown +920 -0
- data/Rakefile +57 -0
- data/bin/resque +81 -0
- data/bin/resque-web +31 -0
- data/lib/resque.rb +578 -0
- data/lib/resque/data_store.rb +326 -0
- data/lib/resque/errors.rb +21 -0
- data/lib/resque/failure.rb +119 -0
- data/lib/resque/failure/airbrake.rb +33 -0
- data/lib/resque/failure/base.rb +73 -0
- data/lib/resque/failure/multiple.rb +68 -0
- data/lib/resque/failure/redis.rb +128 -0
- data/lib/resque/failure/redis_multi_queue.rb +104 -0
- data/lib/resque/helpers.rb +48 -0
- data/lib/resque/job.rb +296 -0
- 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 +78 -0
- data/lib/resque/server.rb +299 -0
- data/lib/resque/server/helpers.rb +64 -0
- data/lib/resque/server/public/favicon.ico +0 -0
- data/lib/resque/server/public/idle.png +0 -0
- data/lib/resque/server/public/jquery-1.12.4.min.js +5 -0
- data/lib/resque/server/public/jquery.relatize_date.js +95 -0
- data/lib/resque/server/public/poll.png +0 -0
- data/lib/resque/server/public/ranger.js +78 -0
- data/lib/resque/server/public/reset.css +44 -0
- data/lib/resque/server/public/style.css +91 -0
- data/lib/resque/server/public/working.png +0 -0
- data/lib/resque/server/test_helper.rb +19 -0
- data/lib/resque/server/views/error.erb +1 -0
- data/lib/resque/server/views/failed.erb +29 -0
- 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/key_sets.erb +17 -0
- data/lib/resque/server/views/key_string.erb +11 -0
- data/lib/resque/server/views/layout.erb +44 -0
- data/lib/resque/server/views/next_more.erb +22 -0
- data/lib/resque/server/views/overview.erb +4 -0
- data/lib/resque/server/views/queues.erb +58 -0
- data/lib/resque/server/views/stats.erb +62 -0
- data/lib/resque/server/views/workers.erb +111 -0
- data/lib/resque/server/views/working.erb +72 -0
- data/lib/resque/stat.rb +58 -0
- data/lib/resque/tasks.rb +72 -0
- data/lib/resque/thread_signal.rb +45 -0
- data/lib/resque/vendor/utf8_util.rb +26 -0
- data/lib/resque/vendor/utf8_util/utf8_util_18.rb +91 -0
- data/lib/resque/vendor/utf8_util/utf8_util_19.rb +6 -0
- data/lib/resque/version.rb +3 -0
- data/lib/resque/worker.rb +892 -0
- data/lib/resqueue.rb +4 -0
- data/lib/tasks/redis.rake +161 -0
- data/lib/tasks/resque.rake +2 -0
- metadata +197 -0
@@ -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,17 @@
|
|
1
|
+
<% if key = params[:key] %>
|
2
|
+
|
3
|
+
<p class='sub'><%= page_entries_info start = params[:start].to_i, start + 20, size = redis_get_size(key) %></p>
|
4
|
+
|
5
|
+
<h1>Key "<%= key %>" is a <%= resque.redis.type key %></h1>
|
6
|
+
<table>
|
7
|
+
<% for row in redis_get_value_as_array(key, start) %>
|
8
|
+
<tr>
|
9
|
+
<td>
|
10
|
+
<%= row %>
|
11
|
+
</td>
|
12
|
+
</tr>
|
13
|
+
<% end %>
|
14
|
+
</table>
|
15
|
+
|
16
|
+
<%= partial :next_more, :start => start, :size => size, :per_page => 20 %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,44 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>Resque</title>
|
6
|
+
<link href="<%=u 'reset.css' %>" media="screen" rel="stylesheet" type="text/css">
|
7
|
+
<link href="<%=u 'style.css' %>" media="screen" rel="stylesheet" type="text/css">
|
8
|
+
<script src="<%=u 'jquery-1.12.4.min.js' %>" type="text/javascript"></script>
|
9
|
+
<script src="<%=u 'jquery.relatize_date.js' %>" type="text/javascript"></script>
|
10
|
+
<script src="<%=u 'ranger.js' %>" type="text/javascript"></script>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<div class="header">
|
14
|
+
<ul class='nav'>
|
15
|
+
<% tabs.each do |tab_name| %>
|
16
|
+
<%= tab tab_name %>
|
17
|
+
<% end %>
|
18
|
+
</ul>
|
19
|
+
<% if Resque.redis.namespace != :resque %>
|
20
|
+
<abbr class="namespace" title="Resqueue's Redis Namespace">
|
21
|
+
<%= Resque.redis.namespace %>
|
22
|
+
</abbr>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<% if @subtabs %>
|
27
|
+
<ul class='subnav'>
|
28
|
+
<% for subtab in @subtabs %>
|
29
|
+
<li <%= class_if_current "#{current_section}/#{subtab}" %>><a href="<%= current_section %>/<%= subtab %>"><span><%= subtab %></span></a></li>
|
30
|
+
<% end %>
|
31
|
+
</ul>
|
32
|
+
<% end %>
|
33
|
+
|
34
|
+
<div id="main">
|
35
|
+
<%= yield %>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div id="footer">
|
39
|
+
<p>Powered by <a href="http://github.com/oss92/resqueue">Resqueue</a> v<%=Resque::Version%> based on <a href="http://github.com/resque/resque">Resque</a> project</p>
|
40
|
+
<p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%=Resque.redis_id%></p>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
</body>
|
44
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
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
|
+
<p class='pagination'>
|
6
|
+
<% if start + per_page <= size %>
|
7
|
+
<a href="<%= current_page %>?start=<%= start + per_page %>" class='more'>« Next</a>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<% (size / per_page.to_f - 1).ceil.downto(0).each do |page_num| %>
|
11
|
+
<% if start == page_num * per_page %>
|
12
|
+
<%= page_num %>
|
13
|
+
<% else %>
|
14
|
+
<a href="<%= current_page %>?start=<%= page_num * per_page %>"> <%= page_num %></a>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<% if start - per_page >= 0 %>
|
19
|
+
<a href="<%= current_page %>?start=<%= start - per_page %>" class='less'>Previous »</a>
|
20
|
+
<% end %>
|
21
|
+
</p>
|
22
|
+
<%end%>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<% @subtabs = resque.queues unless partial? || params[:id].nil? %>
|
2
|
+
|
3
|
+
<% if queue = params[:id] %>
|
4
|
+
|
5
|
+
<h1>Pending jobs on <span class='hl'><%= queue %></span></h1>
|
6
|
+
<form method="POST" action="<%=u "/queues/#{queue}/remove" %>" class='remove-queue'>
|
7
|
+
<input type='submit' name='' value='Remove Queue' onclick='return confirm("Are you absolutely sure? This cannot be undone.");' />
|
8
|
+
</form>
|
9
|
+
<p class='sub'><%= page_entries_info start = params[:start].to_i, start + 19, size = resque.size(queue), 'job' %></p>
|
10
|
+
<table class='jobs'>
|
11
|
+
<tr>
|
12
|
+
<th>Class</th>
|
13
|
+
<th>Args</th>
|
14
|
+
</tr>
|
15
|
+
<% for job in (jobs = resque.peek(queue, start, 20)) %>
|
16
|
+
<tr>
|
17
|
+
<td class='class'><%= job['class'] %></td>
|
18
|
+
<td class='args'><%=h job['args'].inspect %></td>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
<% if jobs.empty? %>
|
22
|
+
<tr>
|
23
|
+
<td class='no-data' colspan='2'>There are no pending jobs in this queue</td>
|
24
|
+
</tr>
|
25
|
+
<% end %>
|
26
|
+
</table>
|
27
|
+
<%= partial :next_more, :start => start, :size => size, :per_page => 20 %>
|
28
|
+
<% else %>
|
29
|
+
|
30
|
+
<h1 class='wi'>Queues</h1>
|
31
|
+
<p class='intro'>The list below contains all the registered queues with the number of jobs currently in the queue. Select a queue from above to view all jobs currently pending on the queue.</p>
|
32
|
+
<table class='queues'>
|
33
|
+
<tr>
|
34
|
+
<th>Name</th>
|
35
|
+
<th>Jobs</th>
|
36
|
+
</tr>
|
37
|
+
<% resque.queues.sort_by { |q| q.to_s }.each do |queue| %>
|
38
|
+
<tr>
|
39
|
+
<td class='queue'><a class="queue" href="<%= u "queues/#{queue}" %>"><%= queue %></a></td>
|
40
|
+
<td class='size'><%= resque.size queue %></td>
|
41
|
+
</tr>
|
42
|
+
<% end %>
|
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 %>
|
56
|
+
</table>
|
57
|
+
|
58
|
+
<% end %>
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<% @subtabs = %w( resque redis keys ) %>
|
2
|
+
|
3
|
+
<% if params[:key] %>
|
4
|
+
|
5
|
+
<%= partial resque.redis.type(params[:key]).eql?("string") ? :key_string : :key_sets %>
|
6
|
+
|
7
|
+
<% elsif params[:id] == "resque" %>
|
8
|
+
|
9
|
+
<h1><%= resque %></h1>
|
10
|
+
<table class='stats'>
|
11
|
+
<% for key, value in resque.info.to_a.sort_by { |i| i[0].to_s } %>
|
12
|
+
<tr>
|
13
|
+
<th>
|
14
|
+
<%= key %>
|
15
|
+
</th>
|
16
|
+
<td>
|
17
|
+
<%= value %>
|
18
|
+
</td>
|
19
|
+
</tr>
|
20
|
+
<% end %>
|
21
|
+
</table>
|
22
|
+
|
23
|
+
<% elsif params[:id] == 'redis' %>
|
24
|
+
|
25
|
+
<h1><%= resque.redis_id %></h1>
|
26
|
+
<table class='stats'>
|
27
|
+
<% for key, value in resque.redis.info.to_a.sort_by { |i| i[0].to_s } %>
|
28
|
+
<tr>
|
29
|
+
<th>
|
30
|
+
<%= key %>
|
31
|
+
</th>
|
32
|
+
<td>
|
33
|
+
<%= value %>
|
34
|
+
</td>
|
35
|
+
</tr>
|
36
|
+
<% end %>
|
37
|
+
</table>
|
38
|
+
|
39
|
+
<% elsif params[:id] == 'keys' %>
|
40
|
+
|
41
|
+
<h1>Keys owned by <%= resque %></h1>
|
42
|
+
<p class='sub'>(All keys are actually prefixed with "<%= Resque.redis.namespace %>:")</p>
|
43
|
+
<table class='stats'>
|
44
|
+
<tr>
|
45
|
+
<th>key</th>
|
46
|
+
<th>type</th>
|
47
|
+
<th>size</th>
|
48
|
+
</tr>
|
49
|
+
<% for key in resque.keys.sort %>
|
50
|
+
<tr>
|
51
|
+
<th>
|
52
|
+
<a href="<%=u "/stats/keys/#{key}" %>"><%= key %></a>
|
53
|
+
</th>
|
54
|
+
<td><%= resque.redis.type key %></td>
|
55
|
+
<td><%= redis_get_size key %></td>
|
56
|
+
</tr>
|
57
|
+
<% end %>
|
58
|
+
</table>
|
59
|
+
|
60
|
+
<% else %>
|
61
|
+
|
62
|
+
<% end %>
|
@@ -0,0 +1,111 @@
|
|
1
|
+
<% @subtabs = worker_hosts.keys.sort unless worker_hosts.size == 1 %>
|
2
|
+
|
3
|
+
<% if params[:id] && worker = Resque::Worker.find(params[:id]) %>
|
4
|
+
|
5
|
+
<h1>Worker <%= worker %></h1>
|
6
|
+
<table class='workers'>
|
7
|
+
<tr>
|
8
|
+
<th> </th>
|
9
|
+
<th>Host</th>
|
10
|
+
<th>Pid</th>
|
11
|
+
<th>Started</th>
|
12
|
+
<th>Heartbeat</th>
|
13
|
+
<th>Queues</th>
|
14
|
+
<th>Processed</th>
|
15
|
+
<th>Failed</th>
|
16
|
+
<th>Processing</th>
|
17
|
+
</tr>
|
18
|
+
<tr>
|
19
|
+
<td class='icon'><img src="<%=u state = worker.state %>.png" alt="<%= state %>" title="<%= state %>"></td>
|
20
|
+
|
21
|
+
<% host, pid, queues = worker.to_s.split(':') %>
|
22
|
+
<td><%= host %></td>
|
23
|
+
<td><%= pid %></td>
|
24
|
+
<td><span class="time"><%= worker.started %></span></td>
|
25
|
+
<td><span class="time"><%= worker.heartbeat %></span></td>
|
26
|
+
<td class='queues'><%= queues.split(',').map { |q| '<a class="queue-tag" href="' + u("/queues/#{q}") + '">' + q + '</a>'}.join('') %></td>
|
27
|
+
<td><%= worker.processed %></td>
|
28
|
+
<td><%= worker.failed %></td>
|
29
|
+
<td class='process'>
|
30
|
+
<% data = worker.processing || {} %>
|
31
|
+
<% if data['queue'] %>
|
32
|
+
<code><%= data['payload']['class'] %></code>
|
33
|
+
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= data['run_at'] %></a></small>
|
34
|
+
<% else %>
|
35
|
+
<span class='waiting'>Waiting for a job...</span>
|
36
|
+
<% end %>
|
37
|
+
</td>
|
38
|
+
</tr>
|
39
|
+
</table>
|
40
|
+
|
41
|
+
<% elsif params[:id] && !worker_hosts.keys.include?(params[:id]) && params[:id] != 'all' %>
|
42
|
+
|
43
|
+
<h1>Worker doesn't exist</h1>
|
44
|
+
|
45
|
+
<% elsif worker_hosts.size == 1 || params[:id] %>
|
46
|
+
|
47
|
+
<% if worker_hosts.size == 1 || params[:id] == 'all' %>
|
48
|
+
<% workers = Resque.workers %>
|
49
|
+
<% else %>
|
50
|
+
<% workers = worker_hosts[params[:id]].map { |id| Resque::Worker.find(id) } %>
|
51
|
+
<% end %>
|
52
|
+
|
53
|
+
<h1 class='wi'><%= workers.size %> Workers</h1>
|
54
|
+
<p class='intro'>The workers listed below are all registered as active on your system.</p>
|
55
|
+
<table class='workers'>
|
56
|
+
<tr>
|
57
|
+
<th> </th>
|
58
|
+
<th>Where</th>
|
59
|
+
<th>Queues</th>
|
60
|
+
<th>Processing</th>
|
61
|
+
</tr>
|
62
|
+
<% for worker in (workers = workers.sort_by { |w| w.to_s }) %>
|
63
|
+
<tr class="<%=state = worker.state%>">
|
64
|
+
<td class='icon'><img src="<%=u state %>.png" alt="<%= state %>" title="<%= state %>"></td>
|
65
|
+
|
66
|
+
<% host, pid, queues = worker.to_s.split(':') %>
|
67
|
+
<td class='where'><a href="<%=u "workers/#{worker}"%>"><%= host %>:<%= pid %></a></td>
|
68
|
+
<td class='queues'><%= queues.split(',').map { |q| '<a class="queue-tag" href="' + u("/queues/#{q}") + '">' + q + '</a>'}.join('') %></td>
|
69
|
+
|
70
|
+
<td class='process'>
|
71
|
+
<% data = worker.processing || {} %>
|
72
|
+
<% if data['queue'] %>
|
73
|
+
<code><%= data['payload']['class'] %></code>
|
74
|
+
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= data['run_at'] %></a></small>
|
75
|
+
<% else %>
|
76
|
+
<span class='waiting'>Waiting for a job...</span>
|
77
|
+
<% end %>
|
78
|
+
</td>
|
79
|
+
</tr>
|
80
|
+
<% end %>
|
81
|
+
<% if workers.empty? %>
|
82
|
+
<tr>
|
83
|
+
<td colspan='4' class='no-data'>There are no registered workers</td>
|
84
|
+
</tr>
|
85
|
+
<% end %>
|
86
|
+
</table>
|
87
|
+
<%=poll%>
|
88
|
+
|
89
|
+
<% else %>
|
90
|
+
<% @subtabs = [] %>
|
91
|
+
<h1 class='wi'>Workers</h1>
|
92
|
+
<p class='intro'>The hostnames below all have registered workers. Select a hostname to view its workers, or "all" to see all workers.</p>
|
93
|
+
<table class='queues'>
|
94
|
+
<tr>
|
95
|
+
<th>Hostname</th>
|
96
|
+
<th>Workers</th>
|
97
|
+
</tr>
|
98
|
+
<% for hostname, workers in worker_hosts.sort_by { |h,w| h } %>
|
99
|
+
<tr>
|
100
|
+
<td class='queue'><a class="queue" href="<%= u "workers/#{hostname}" %>"><%= hostname %></a></td>
|
101
|
+
<td class='size'><%= workers.size %></td>
|
102
|
+
</tr>
|
103
|
+
<% end %>
|
104
|
+
<tr class="failed">
|
105
|
+
<td class='queue failed'><a class="queue" href="<%= u "workers/all" %>">all workers</a></td>
|
106
|
+
<td class='size'><%= Resque.workers.size %></td>
|
107
|
+
</tr>
|
108
|
+
</table>
|
109
|
+
|
110
|
+
|
111
|
+
<% end %>
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<% if params[:id] && (worker = Resque::Worker.find(params[:id])) && (data = worker.job) %>
|
2
|
+
<h1><%= worker %>'s job</h1>
|
3
|
+
|
4
|
+
<table>
|
5
|
+
<tr>
|
6
|
+
<th> </th>
|
7
|
+
<th>Where</th>
|
8
|
+
<th>Queue</th>
|
9
|
+
<th>Started</th>
|
10
|
+
<th>Class</th>
|
11
|
+
<th>Args</th>
|
12
|
+
</tr>
|
13
|
+
<tr>
|
14
|
+
<td><img src="<%=u 'working.png' %>" alt="working" title="working"></td>
|
15
|
+
<% host, pid, _ = worker.to_s.split(':') %>
|
16
|
+
<td><a href="<%=u "/workers/#{worker}" %>"><%= host %>:<%= pid %></a></td>
|
17
|
+
<% queue = data['queue'] %>
|
18
|
+
<td><a class="queue" href="<%=u "/queues/#{queue}" %>"><%= queue %></a></td>
|
19
|
+
<td><span class="time"><%= data['run_at'] %></span></td>
|
20
|
+
<% payload = data.key?('payload') ? data['payload'] : {} %>
|
21
|
+
<td>
|
22
|
+
<code><%= payload.key?('class') ? payload['class'] : "—" %></code>
|
23
|
+
</td>
|
24
|
+
<td><%=h payload.key?('args') ? payload['args'].inspect : "—" %></td>
|
25
|
+
</tr>
|
26
|
+
</table>
|
27
|
+
|
28
|
+
<% else %>
|
29
|
+
|
30
|
+
<%
|
31
|
+
workers = resque.working
|
32
|
+
jobs = workers.collect {|w| w.job }
|
33
|
+
worker_jobs = workers.zip(jobs)
|
34
|
+
worker_jobs = worker_jobs.reject { |w, j| w.idle? }
|
35
|
+
%>
|
36
|
+
|
37
|
+
<h1 class='wi'><%= worker_jobs.size %> of <%= resque.workers.size %> Workers Working</h1>
|
38
|
+
<p class='intro'>The list below contains all workers which are currently running a job.</p>
|
39
|
+
<table class='workers'>
|
40
|
+
<tr>
|
41
|
+
<th> </th>
|
42
|
+
<th>Where</th>
|
43
|
+
<th>Queue</th>
|
44
|
+
<th>Processing</th>
|
45
|
+
</tr>
|
46
|
+
<% if worker_jobs.empty? %>
|
47
|
+
<tr>
|
48
|
+
<td colspan="4" class='no-data'>Nothing is happening right now...</td>
|
49
|
+
</tr>
|
50
|
+
<% end %>
|
51
|
+
|
52
|
+
<% worker_jobs.sort_by {|w, j| j['run_at'] ? j['run_at'].to_s() : '' }.each do |worker, job| %>
|
53
|
+
<tr>
|
54
|
+
<td class='icon'><img src="<%=u state = worker.state %>.png" alt="<%= state %>" title="<%= state %>"></td>
|
55
|
+
<% host, pid, queues = worker.to_s.split(':') %>
|
56
|
+
<td class='where'><a href="<%=u "/workers/#{worker}" %>"><%= host %>:<%= pid %></a></td>
|
57
|
+
<td class='queues queue'>
|
58
|
+
<a class="queue-tag" href="<%=u "/queues/#{job['queue']}" %>"><%= job['queue'] %></a>
|
59
|
+
</td>
|
60
|
+
<td class='process'>
|
61
|
+
<% if job['queue'] %>
|
62
|
+
<code><%= job['payload']['class'] %></code>
|
63
|
+
<small><a class="queue time" href="<%=u "/working/#{worker}" %>"><%= job['run_at'] %></a></small>
|
64
|
+
<% else %>
|
65
|
+
<span class='waiting'>Waiting for a job...</span>
|
66
|
+
<% end %>
|
67
|
+
</td>
|
68
|
+
</tr>
|
69
|
+
<% end %>
|
70
|
+
</table>
|
71
|
+
|
72
|
+
<% end %>
|
data/lib/resque/stat.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
module Resque
|
2
|
+
# The stat subsystem. Used to keep track of integer counts.
|
3
|
+
#
|
4
|
+
# Get a stat: Stat[name]
|
5
|
+
# Incr a stat: Stat.incr(name)
|
6
|
+
# Decr a stat: Stat.decr(name)
|
7
|
+
# Kill a stat: Stat.clear(name)
|
8
|
+
module Stat
|
9
|
+
extend self
|
10
|
+
|
11
|
+
# Direct access to the Redis instance.
|
12
|
+
def redis
|
13
|
+
Resque.redis
|
14
|
+
end
|
15
|
+
alias :data_store :redis
|
16
|
+
|
17
|
+
# Returns the int value of a stat, given a string stat name.
|
18
|
+
def get(stat)
|
19
|
+
data_store.stat(stat)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Alias of `get`
|
23
|
+
def [](stat)
|
24
|
+
get(stat)
|
25
|
+
end
|
26
|
+
|
27
|
+
# For a string stat name, increments the stat by one.
|
28
|
+
#
|
29
|
+
# Can optionally accept a second int parameter. The stat is then
|
30
|
+
# incremented by that amount.
|
31
|
+
def incr(stat, by = 1)
|
32
|
+
data_store.increment_stat(stat,by)
|
33
|
+
end
|
34
|
+
|
35
|
+
# Increments a stat by one.
|
36
|
+
def <<(stat)
|
37
|
+
incr stat
|
38
|
+
end
|
39
|
+
|
40
|
+
# For a string stat name, decrements the stat by one.
|
41
|
+
#
|
42
|
+
# Can optionally accept a second int parameter. The stat is then
|
43
|
+
# decremented by that amount.
|
44
|
+
def decr(stat, by = 1)
|
45
|
+
data_store.decremet_stat(stat,by)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Decrements a stat by one.
|
49
|
+
def >>(stat)
|
50
|
+
decr stat
|
51
|
+
end
|
52
|
+
|
53
|
+
# Removes a stat from Redis, effectively setting it to 0.
|
54
|
+
def clear(stat)
|
55
|
+
data_store.clear_stat(stat)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|