Skip to content

Commit d6b229a

Browse files
committed
Merge branch 'master' into 2.0
2 parents a7307ac + ed28d26 commit d6b229a

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

README.markdown

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -660,13 +660,13 @@ If you wish to have a Proc called before the worker forks for the
660660
first time, you can add it in the initializer like so:
661661

662662
Resque.before_first_fork do
663-
puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
663+
puts "Call me once before the worker forks the first time"
664664
end
665665

666666
You can also run a hook before _every_ fork:
667667

668668
Resque.before_fork do |job|
669-
puts "CALL ME BEFORE THE WORKER FORKS"
669+
puts "Call me before the worker forks"
670670
end
671671

672672
The `before_fork` hook will be run in the **parent** process. So, be
@@ -676,7 +676,7 @@ the worker.
676676
And after forking:
677677

678678
Resque.after_fork do |job|
679-
puts "CALL ME AFTER THE WORKER FORKS"
679+
puts "Call me after the worker forks"
680680
end
681681

682682
The `after_fork` hook will be run in the child process and is passed
@@ -719,10 +719,18 @@ Try it out by looking at the README, found at `examples/demo/README.markdown`.
719719
Monitoring
720720
----------
721721

722+
### god
723+
722724
If you're using god to monitor Resque, we have provided example
723725
configs in `examples/god/`. One is for starting / stopping workers,
724726
the other is for killing workers that have been running too long.
725727

728+
### monit
729+
730+
If you're using monit, `examples/monit/resque.monit` is provided free
731+
of charge. This is **not** used by GitHub in production, so please
732+
send patches for any tweaks or improvements you can make to it.
733+
726734

727735
Development
728736
-----------

lib/resque/server.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def current_section
2020
end
2121

2222
def current_page
23-
url request.path_info.sub('/','').downcase
23+
url request.path_info.sub('/','')
2424
end
2525

2626
def url(*path_parts)
@@ -153,7 +153,11 @@ def show(page, layout = true)
153153

154154
get "/failed/requeue/:index" do
155155
Resque::Failure.requeue(params[:index])
156-
redirect u('failed')
156+
if request.xhr?
157+
return Resque::Failure.all(params[:index])['retried_at']
158+
else
159+
redirect u('failed')
160+
end
157161
end
158162

159163
get "/stats" do

lib/resque/server/public/ranger.js

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
$(function() {
22
var poll_interval = 2
33

4-
$('.time').each(function(){
4+
var relatizer = function(){
55
var dt = $(this).text(), relatized = $.relatizeDate(this)
66
if ($(this).parents("a").length > 0 || $(this).is("a")) {
77
$(this).relatizeDate()
@@ -16,15 +16,19 @@ $(function() {
1616
'</span><span class="relatized_time">' +
1717
relatized + '</span>') )
1818
}
19-
})
19+
};
20+
21+
$('.time').each(relatizer);
2022

2123
$('.time a.toggle_format .date_time').hide()
2224

23-
$('.time a.toggle_format').click(function(){
25+
var format_toggler = function(){
2426
$('.time a.toggle_format span').toggle()
2527
$(this).attr('title', $('span:hidden',this).text())
2628
return false
27-
})
29+
};
30+
31+
$('.time a.toggle_format').click(format_toggler);
2832

2933
$('.backtrace').click(function() {
3034
$(this).next().toggle()
@@ -45,4 +49,19 @@ $(function() {
4549

4650
return false
4751
})
52+
53+
$('ul.failed a[rel=retry]').click(function() {
54+
var href = $(this).attr('href');
55+
$(this).text('Retrying...');
56+
var parent = $(this).parent();
57+
$.ajax({dataType: 'text', type: 'get', url: href, success: function(data) {
58+
parent.html('Retried <b><span class="time">' + data + '</span></b>');
59+
relatizer.apply($('.time', parent));
60+
$('.date_time', parent).hide();
61+
$('a.toggle_format span', parent).click(format_toggler);
62+
}});
63+
return false;
64+
})
65+
66+
4867
})

lib/resque/server/views/failed.erb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<% if job['retried_at'] %>
2424
Retried <b><span class="time"><%= job['retried_at'] %></span></b>
2525
<% else %>
26-
<a href="<%= u "failed/requeue/#{start + index - 1}" %>">Retry</a>
26+
<a href="<%= u "failed/requeue/#{start + index - 1}" %>" rel="retry">Retry</a>
2727
<% end %>
2828
</div>
2929
</dd>
@@ -46,3 +46,4 @@
4646
</ul>
4747

4848
<%= partial :next_more, :start => start, :size => size %>
49+

lib/resque/worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def process(job = nil)
143143
return unless job ||= reserve
144144

145145
begin
146+
job.worker = self
146147
run_hook :after_fork, job
147148
working_on job
148149
job.perform
@@ -332,7 +333,6 @@ def unregister_worker
332333
# Given a job, tells Redis we're working on it. Useful for seeing
333334
# what workers are doing and when.
334335
def working_on(job)
335-
job.worker = self
336336
data = encode \
337337
:queue => job.queue,
338338
:run_at => Time.now.to_i,

0 commit comments

Comments
 (0)