Created
November 21, 2012 14:51
-
-
Save kyanny/4125211 to your computer and use it in GitHub Desktop.
Resque Failure Backend example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'resque/failure/base' | |
require 'mail' | |
module Resque | |
module Failure | |
class EmailNotification < Base | |
def save | |
subject = "[FATAL] Resque #{queue}:#{worker}" | |
body = "#{exception.class} #{exception.to_s}\n#{exception.backtrace.join("\n")}" | |
Mail.defaults do | |
delivery_method :sendmail | |
end | |
Mail.deliver do | |
from 'kyanny@gmail.com' | |
to 'kyanny@gmail.com' | |
subject subject | |
body body | |
end | |
rescue => e | |
puts "#{e.class} #{e.to_s}" | |
puts e.backtrace.join("\n") | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source :rubygems | |
gem 'resque' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GEM | |
remote: http://rubygems.org/ | |
specs: | |
multi_json (1.3.7) | |
rack (1.4.1) | |
rack-protection (1.2.0) | |
rack | |
redis (3.0.2) | |
redis-namespace (1.2.1) | |
redis (~> 3.0.0) | |
resque (1.23.0) | |
multi_json (~> 1.0) | |
redis-namespace (~> 1.0) | |
sinatra (>= 0.9.2) | |
vegas (~> 0.1.2) | |
sinatra (1.3.3) | |
rack (~> 1.3, >= 1.3.6) | |
rack-protection (~> 1.2) | |
tilt (~> 1.3, >= 1.3.3) | |
tilt (1.3.3) | |
vegas (0.1.11) | |
rack (>= 1.0.0) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
resque |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyException < Exception; end | |
module Job | |
@queue = :job | |
def self.perform | |
raise MyException, 'Error! Error! Error!' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './resque_config' | |
require './job' | |
require 'resque/tasks' | |
desc 'enqueue' | |
task :enqueue do | |
Resque.enqueue(Job) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'resque' | |
require 'resque/failure/multiple' | |
require 'resque/failure/redis' | |
require './email_notification' | |
Resque::Failure::Multiple.configure do |multi| | |
multi.classes = [Resque::Failure::Redis, Resque::Failure::EmailNotification] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment