Skip to content

Commit 6d417e6

Browse files
committed
Merge branch 'master' into hook-plugin
2 parents 14ee8e8 + ed28d26 commit 6d417e6

File tree

17 files changed

+211
-66
lines changed

17 files changed

+211
-66
lines changed

CONTRIBUTORS

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
11
* Chris Wanstrath
22
* gravis
3-
* John Barnette
43
* scotttam
4+
* John Barnette
5+
* Mike Mangino
6+
* Rob Hanlon
7+
* Jason Amster
58
* Aaron Quint
69
* Adam Cooke
710
* Ashley Martens
8-
* Jason Amster
9-
* Mike Mangino
10-
* Rob Hanlon
11-
* jgeiger
12-
* Roman Heinrich
13-
* Thibaut Barrère
1411
* Matt Duncan
12+
* Michael Dwan
1513
* Daniel Ceballos
16-
* Ben VandenBos
17-
* Christos Trochalakis
18-
* Roland Moriz
14+
* Roman Heinrich
15+
* Thibaut Barrère
16+
* jgeiger
1917
* Simon Rozet
20-
* Brian P O'Rourke
21-
* PJ Hyett
18+
* Dave Hoover
19+
* Christos Trochalakis
20+
* Ben VandenBos
21+
* snusnu
22+
* Arthur Zapparoli
2223
* Ben Marini
24+
* Brian P O'Rourke
25+
* Jim Remsik and Les Hill
2326
* Karel Minarik
27+
* Luc Castera
2428
* Masatomo Nakano
2529
* Matt Palmer
26-
* Michael Dwan
27-
* Dave Hoover
28-
* Arthur Zapparoli
30+
* PJ Hyett
31+
* Roland Moriz
32+
* malomalo

HISTORY.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
## 1.6.1 (2010-??-??)
1+
## 1.6.1 (2010-03-25)
22

33
* Bugfix: Workers may not be clearing their state correctly on
44
shutdown
55
* Added example monit config.
66
* Exception class is now recorded when an error is raised in a
77
worker.
8-
* resque-web: Unit tests
8+
* web: Unit tests
9+
* web: Show namespace in header and footer
10+
* web: Remove a queue
11+
* web: Retry failed jobs
912

1013
## 1.6.0 (2010-03-09)
1114

README.markdown

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ tool that's best for your app.
485485
Installing Redis
486486
----------------
487487

488+
Resque requires Redis 0.900 or higher.
489+
488490
Resque uses Redis' lists for its queues. It also stores worker state
489491
data in Redis.
490492

@@ -529,6 +531,9 @@ Resque Dependencies
529531
If you cannot install `yajl-ruby` (JRuby?), you can install the `json`
530532
gem and Resque will use it instead.
531533

534+
When problems arise, make sure you have the newest versions of the
535+
`redis` and `redis-namespace` gems.
536+
532537

533538
Installing Resque
534539
-----------------
@@ -655,13 +660,13 @@ If you wish to have a Proc called before the worker forks for the
655660
first time, you can add it in the initializer like so:
656661

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

661666
You can also run a hook before _every_ fork:
662667

663668
Resque.before_fork do |job|
664-
puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
669+
puts "Call me before the worker forks"
665670
end
666671

667672
The `before_fork` hook will be run in the **parent** process. So, be
@@ -671,7 +676,7 @@ the worker.
671676
And after forking:
672677

673678
Resque.after_fork do |job|
674-
puts "CALL ME ONCE BEFORE THE WORKER FORKS THE FIRST TIME"
679+
puts "Call me after the worker forks"
675680
end
676681

677682
The `after_fork` hook will be run in the child process and is passed
@@ -714,10 +719,18 @@ Try it out by looking at the README, found at `examples/demo/README.markdown`.
714719
Monitoring
715720
----------
716721

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

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+
721734

722735
Development
723736
-----------

examples/demo/Rakefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
22
require 'resque/tasks'
33
require 'job'
4+
5+
desc "Start the demo using `rackup`"
6+
task :start do
7+
exec "rackup config.ru"
8+
end

lib/resque/failure.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,8 @@ def self.clear
5959
backend.clear
6060
end
6161

62+
def self.requeue(index)
63+
backend.requeue(index)
64+
end
6265
end
6366
end

lib/resque/failure/base.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ def self.url
4848
# Clear all failure objects
4949
def self.clear
5050
end
51+
52+
def self.requeue(index)
53+
end
5154

5255
# Logging!
5356
def log(message)

lib/resque/failure/hoptoad.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module Failure
88
#
99
# To use it, put this code in an initializer, Rake task, or wherever:
1010
#
11+
# require 'resque/failure/hoptoad'
12+
#
1113
# Resque::Failure::Hoptoad.configure do |config|
1214
# config.api_key = 'blah'
1315
# config.secure = true

lib/resque/failure/redis.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ def self.clear
2929
Resque.redis.del(:failed)
3030
end
3131

32+
def self.requeue(index)
33+
item = all(index)
34+
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
35+
Resque.redis.lset(:failed, index, Resque.encode(item))
36+
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
37+
end
3238
end
3339
end
3440
end

lib/resque/server.rb

Lines changed: 15 additions & 1 deletion
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)
@@ -124,6 +124,11 @@ def show(page, layout = true)
124124
show page
125125
end
126126
end
127+
128+
post "/queues/:id/remove" do
129+
Resque.remove_queue(params[:id])
130+
redirect u('queues')
131+
end
127132

128133
%w( overview workers ).each do |page|
129134
get "/#{page}.poll" do
@@ -145,6 +150,15 @@ def show(page, layout = true)
145150
Resque::Failure.clear
146151
redirect u('failed')
147152
end
153+
154+
get "/failed/requeue/:index" do
155+
Resque::Failure.requeue(params[:index])
156+
if request.xhr?
157+
return Resque::Failure.all(params[:index])['retried_at']
158+
else
159+
redirect u('failed')
160+
end
161+
end
148162

149163
get "/stats" do
150164
redirect url("/stats/resque")

lib/resque/server/public/ranger.js

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,67 @@
1-
var poll_interval = 2;
2-
31
$(function() {
2+
var poll_interval = 2
3+
4+
var relatizer = function(){
5+
var dt = $(this).text(), relatized = $.relatizeDate(this)
6+
if ($(this).parents("a").length > 0 || $(this).is("a")) {
7+
$(this).relatizeDate()
8+
if (!$(this).attr('title')) {
9+
$(this).attr('title', dt)
10+
}
11+
} else {
12+
$(this)
13+
.text('')
14+
.append( $('<a href="#" class="toggle_format" title="' + dt + '" />')
15+
.append('<span class="date_time">' + dt +
16+
'</span><span class="relatized_time">' +
17+
relatized + '</span>') )
18+
}
19+
};
20+
21+
$('.time').each(relatizer);
22+
23+
$('.time a.toggle_format .date_time').hide()
24+
25+
var format_toggler = function(){
26+
$('.time a.toggle_format span').toggle()
27+
$(this).attr('title', $('span:hidden',this).text())
28+
return false
29+
};
30+
31+
$('.time a.toggle_format').click(format_toggler);
432

5-
$('.time').relatizeDate()
633
$('.backtrace').click(function() {
734
$(this).next().toggle()
835
return false
936
})
10-
37+
1138
$('a[rel=poll]').click(function() {
1239
var href = $(this).attr('href')
1340
$(this).parent().text('Starting...')
1441
$("#main").addClass('polling')
42+
1543
setInterval(function() {
16-
$.ajax({dataType:'text', type:'get', url:href, success:function(data) {
17-
$('#main').html(data)
44+
$.ajax({dataType: 'text', type: 'get', url: href, success: function(data) {
45+
$('#main').html(data)
1846
$('#main .time').relatizeDate()
1947
}})
2048
}, poll_interval * 1000)
49+
2150
return false
2251
})
23-
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+
2467
})

0 commit comments

Comments
 (0)