Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # this goes in lib/resque/failure/notifier.rb
- require 'resque/failure/multiple'
- require 'resque/failure/redis'
- require 'postmark'
- require 'mail'
- module Resque
- module Failure
- class Notifier < Base
- class << self
- attr_accessor :smtp, :sender, :recipients
- end
- def self.configure
- yield self
- Resque::Failure.backend = self unless Resque::Failure.backend == Resque::Failure::Multiple
- end
- def save
- message = Mail.new
- # FIXME stash the api key elsewhere
- message.delivery_method(Mail::Postmark, :api_key => "YOUR-SUPER-SECRET-POSTMARK-KEY-HERE")
- message.from = self.class.sender
- message.to = self.class.recipients
- message.subject = "Resque: #{exception}"
- message.content_type = "text/html"
- # FIXME do something other than a here doc, this is ugly
- message.body = <<EOT
- Queue: #{queue}
- Worker: #{worker}
- #{payload.inspect}
- #{exception}
- #{exception.backtrace.join("\n")}
- EOT
- # pull the trigger
- message.deliver
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment