Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'defunkt' into distributed

  • Loading branch information...
commit 8996224a70e40dec932149d0509b3f2827297e2e 2 parents 22d1fe1 + 11f3fac
@xxx xxx authored
View
3  Gemfile
@@ -9,4 +9,7 @@ group :test do
gem "leftright", :platforms => :mri_18
gem "yajl-ruby", "~>0.8.2", :platforms => :mri
gem "json", "~>1.5.3", :platforms => [:jruby, :rbx]
+ gem "hoptoad_notifier"
+ gem "airbrake"
+ gem "i18n"
end
View
10 HISTORY.md
@@ -1,3 +1,13 @@
+## 1.19.0 (2011-09-01)
+
+* Added Airbrake (formerly Hoptoad) support.
+* Web UI: Added retry all button to failed jobs page
+* Web UI: Show focus outline
+
+## 1.18.6 (2011-08-30)
+
+* Bugfix: Use Rails 3 eager loading for resque:preload
+
## 1.18.5 (2011-08-24)
* Added support for Travis CI
View
8 README.markdown
@@ -469,6 +469,14 @@ run Rack::URLMap.new \
Check `examples/demo/config.ru` for a functional example (including
HTTP basic auth).
+### Rails 3
+
+You can also easily mount Resque on a subpath in your existing Rails 3 app by adding this to your `routes.rb`:
+
+``` ruby
+mount Resque::Server.new, :at => "/resque"
+```
+
Resque vs DelayedJob
--------------------
View
2  examples/god/resque.god
@@ -14,7 +14,7 @@ num_workers.times do |num|
w.uid = 'git'
w.gid = 'git'
- # retart if memory gets too high
+ # restart if memory gets too high
w.transition(:up, :restart) do |on|
on.condition(:memory_usage) do |c|
c.above = 350.megabytes
View
17 lib/resque/failure/airbrake.rb
@@ -0,0 +1,17 @@
+begin
+ require 'airbrake'
+rescue LoadError
+ raise "Can't find 'airbrake' gem. Please add it to your Gemfile or install it."
+end
+
+require 'resque/failure/thoughtbot'
+
+module Resque
+ module Failure
+ class Airbrake < Base
+ include Resque::Failure::Thoughtbot
+
+ @klass = ::Airbrake
+ end
+ end
+end
View
23 lib/resque/failure/hoptoad.rb
@@ -4,6 +4,8 @@
raise "Can't find 'hoptoad_notifier' gem. Please add it to your Gemfile or install it."
end
+require 'resque/failure/thoughtbot'
+
module Resque
module Failure
# A Failure backend that sends exceptions raised by jobs to Hoptoad.
@@ -23,26 +25,9 @@ module Failure
# end
# For more information see https://github.com/thoughtbot/hoptoad_notifier
class Hoptoad < Base
- def self.configure(&block)
- Resque::Failure.backend = self
- HoptoadNotifier.configure(&block)
- end
-
- def self.count
- # We can't get the total # of errors from Hoptoad so we fake it
- # by asking Resque how many errors it has seen.
- Stat[:failed]
- end
-
- def save
- HoptoadNotifier.notify_or_ignore(exception,
- :parameters => {
- :payload_class => payload['class'].to_s,
- :payload_args => payload['args'].inspect
- }
- )
- end
+ include Resque::Failure::Thoughtbot
+ @klass = ::HoptoadNotifier
end
end
end
View
33 lib/resque/failure/thoughtbot.rb
@@ -0,0 +1,33 @@
+module Resque
+ module Failure
+ module Thoughtbot
+ def self.included(base)
+ base.extend(ClassMethods)
+ end
+
+ module ClassMethods
+ attr_accessor :klass
+
+ def configure(&block)
+ Resque::Failure.backend = self
+ klass.configure(&block)
+ end
+
+ def count
+ # We can't get the total # of errors from Hoptoad so we fake it
+ # by asking Resque how many errors it has seen.
+ Stat[:failed]
+ end
+ end
+
+ def save
+ self.class.klass.notify_or_ignore(exception,
+ :parameters => {
+ :payload_class => payload['class'].to_s,
+ :payload_args => payload['args'].inspect
+ }
+ )
+ end
+ end
+ end
+end
View
7 lib/resque/server.rb
@@ -176,6 +176,13 @@ def show_for_polling(page)
redirect u('failed')
end
+ post "/failed/requeue/all" do
+ Resque::Failure.count.times do |num|
+ Resque::Failure.requeue(num)
+ end
+ redirect u('failed')
+ end
+
get "/failed/requeue/:index" do
Resque::Failure.requeue(params[:index])
if request.xhr?
View
4 lib/resque/server/public/reset.css
@@ -16,10 +16,6 @@ table, caption, tbody, tfoot, thead, tr, th, td {
font-family: inherit;
}
-:focus {
- outline: 0;
-}
-
body {
line-height: 1;
}
View
2  lib/resque/server/public/style.css
@@ -80,6 +80,6 @@ body { padding:0; margin:0; }
#main p.pagination a.less { float:left;}
#main p.pagination a.more { float:right;}
-#main form {float:right; margin-top:-10px;}
+#main form {float:right; margin-top:-10px;margin-left:10px;}
#main .time a.toggle_format {text-decoration:none;}
View
5 lib/resque/server/views/failed.erb
@@ -5,9 +5,12 @@
<h1>Failed Jobs</h1>
<%unless failed.empty?%>
-<form method="POST" action="<%=u 'failed/clear'%>" class='clear-failed'>
+<form method="POST" action="<%=u 'failed/clear'%>">
<input type='submit' name='' value='Clear Failed Jobs' />
</form>
+<form method="POST" action="<%=u 'failed/requeue/all'%>">
+ <input type='submit' name='' value='Retry Failed Jobs' />
+</form>
<%end%>
<p class='sub'>Showing <%=start%> to <%= start + 20 %> of <b><%= size = Resque::Failure.count %></b> jobs</p>
View
11 lib/resque/tasks.rb
@@ -42,10 +42,13 @@
# Preload app files if this is Rails
task :preload => :setup do
- if defined?(Rails) && Rails.env == 'production'
- Dir["#{Rails.root}/app/**/*.rb"].each do |file|
- require file
- end
+ if defined?(Rails) && Rails.respond_to?(:application)
+ # Rails 3
+ Rails.application.eager_load!
+ elsif defined?(Rails::Initializer)
+ # Rails 2.3
+ $rails_rake_task = false
+ Rails::Initializer.run :load_application_classes
end
end
end
View
2  lib/resque/version.rb
@@ -1,3 +1,3 @@
module Resque
- Version = VERSION = '1.18.5'
+ Version = VERSION = '1.19.0'
end
View
2  lib/resque/worker.rb
@@ -191,7 +191,7 @@ def perform(job)
def reserve
queues.each do |queue|
log! "Checking #{queue}"
- if job = Resque::Job.reserve(queue)
+ if job = Resque.reserve(queue)
log! "Found job on #{queue}"
return job
end
View
2  lib/tasks/resque.rake
@@ -1,2 +1,2 @@
-$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
+$LOAD_PATH.unshift File.dirname(__FILE__) + '/../../lib'
require 'resque/tasks'
View
27 test/airbrake_test.rb
@@ -0,0 +1,27 @@
+
+require 'test_helper'
+
+begin
+ require 'airbrake'
+rescue LoadError
+ warn "Install airbrake gem to run Airbrake tests."
+end
+
+if defined? Airbrake
+ require 'resque/failure/airbrake'
+ context "Airbrake" do
+ test "should be notified of an error" do
+ exception = StandardError.new("BOOM")
+ worker = Resque::Worker.new(:test)
+ queue = "test"
+ payload = {'class' => Object, 'args' => 66}
+
+ Airbrake.expects(:notify_or_ignore).with(
+ exception,
+ :parameters => {:payload_class => 'Object', :payload_args => '66'})
+
+ backend = Resque::Failure::Airbrake.new(exception, worker, queue, payload)
+ backend.save
+ end
+ end
+end
View
1  test/hoptoad_test.rb
@@ -7,6 +7,7 @@
end
if defined? HoptoadNotifier
+ require 'resque/failure/hoptoad'
context "Hoptoad" do
test "should be notified of an error" do
exception = StandardError.new("BOOM")
Please sign in to comment.
Something went wrong with that request. Please try again.