-
-
Save ctrochalakis/303791 to your computer and use it in GitHub Desktop.
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
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