Skip to content

Commit

Permalink
fix race condition in resque web
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Conway committed Jan 30, 2011
1 parent 0a62442 commit 485184f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/resque/server/views/working.erb
Expand Up @@ -27,8 +27,14 @@

<% else %>
<% workers = resque.working.reject { |w| w.idle? } %>
<h1 class='wi'><%= workers.size %> of <%= resque.workers.size %> Workers Working</h1>
<%
workers = resque.working
jobs = workers.collect {|w| w.job }
worker_jobs = workers.zip(jobs)
worker_jobs = worker_jobs.reject { |w, j| w.idle? }
%>

<h1 class='wi'><%= worker_jobs.size %> of <%= resque.workers.size %> Workers Working</h1>
<p class='intro'>The list below contains all workers which are currently running a job.</p>
<table class='workers'>
<tr>
Expand All @@ -37,15 +43,13 @@
<th>Queue</th>
<th>Processing</th>
</tr>
<% if workers.empty? %>
<% if worker_jobs.empty? %>
<tr>
<td colspan="4" class='no-data'>Nothing is happening right now...</td>
</tr>
<% end %>
<% for worker in workers.sort_by { |w| w.job['run_at'] ? w.job['run_at'] : '' } %>
<% job = worker.job %>

<% worker_jobs.sort_by {|w, j| j['run_at'] ? j['run_at'] : '' }.each do |worker, job| %>
<tr>
<td class='icon'><img src="<%=u state = worker.state %>.png" alt="<%= state %>" title="<%= state %>"></td>
<% host, pid, queues = worker.to_s.split(':') %>
Expand Down

0 comments on commit 485184f

Please sign in to comment.