Skip to content

Instantly share code, notes, and snippets.

@kyanny kyanny/Gemfile
Created Nov 21, 2012

Embed
What would you like to do?
Resque Failure Backend example
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
source :rubygems
gem 'resque'
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
class MyException < Exception; end
module Job
@queue = :job
def self.perform
raise MyException, 'Error! Error! Error!'
end
end
require './resque_config'
require './job'
require 'resque/tasks'
desc 'enqueue'
task :enqueue do
Resque.enqueue(Job)
end
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
You can’t perform that action at this time.