Skip to content

Instantly share code, notes, and snippets.

@ctrochalakis
Forked from assaf/gist:291329
Created February 14, 2010 02:09
Show Gist options
  • Save ctrochalakis/303791 to your computer and use it in GitHub Desktop.
Save ctrochalakis/303791 to your computer and use it in GitHub Desktop.
module Resque
module Failure
# Store a copy of the failure in Redis, so we have access from the UI. Also
# send an email to the developer, so we know something went foul.
class Notifier < Base
def save
# Store in Redis
super
# Create notification email
email = TMail::Mail.new
email.to = "... your email ..."
email.subject = "[Error] #{exception}"
email.body = <<-EOF
Queue: #{queue}
Worker: #{worker}
#{payload.inspect}
#{exception}
#{exception.backtrace.join("\n")}
EOF
Mailer.deliver email
rescue
end
end
end
end
Resque::Failure.backend = Resque::Failure::Notifier if ENV['RAILS_ENV'] == "production"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment