Created
July 26, 2010 11:51
-
-
Save ijonas/490448 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 'exceptional' | |
# Configure Resque connection from config/resque.yml. This file should look | |
# something like: | |
# development: localhost:6379 | |
# test: localhost:6379:15 | |
# production: localhost:6379 | |
# | |
# For use in Rails: | |
# Create a file called lib/exceptional_resque.rb with all this code in it and require it from | |
# your RAILS_ROOT/environment.rb. | |
# | |
# Published under MIT License (c) Ijonas Kisselbach. | |
# Use at your own risk. | |
Resque.redis = YAML.load_file(Rails.root + 'config/resque.yml')[Rails.env] | |
Exceptional::Config.load(Rails.root + "config/exceptional.yml") | |
module Resque | |
module Failure | |
# Logs failure messages. | |
class ExceptionalNotifier < Base | |
def save | |
# the Exceptional magic happens in these two lines. | |
Exceptional::context({:worker => worker, :payload => payload}) | |
Exceptional::Catcher.handle(exception, queue) | |
rescue | |
puts $! | |
end | |
end | |
end | |
end | |
Resque::Failure::Multiple.configure do |multi| | |
# Always stores failure in Redis and writes to log | |
multi.classes = Resque::Failure::Redis, Resque::Failure::ExceptionalNotifier | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment