Guest User

Untitled

a guest
Jun 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # initializer
  2. Resque::Failure::Multiple.configure do |config|
  3. config.classes = [Resque::Failure::Redis, Resque::Failure::Notifier]
  4. end
  5.  
  6.  
  7. #lib/resque/failure/notifier.rb
  8. #===============================
  9.  
  10.  
  11. module Resque
  12. module Failure
  13. # Store a copy of the failure in Redis, so we have access from the UI. Also
  14. # send an email to the developer, so we know something went foul.
  15. class Notifier < Base
  16. def save
  17. # Create notification email
  18. email = TMail::Mail.new
  19. email.to = my_email_address
  20. email.subject = "[Resque] #{exception}"
  21. email.body = <<-EOF
  22. Queue: #{queue}
  23. Worker: #{worker}
  24.  
  25. #{payload.inspect}
  26.  
  27. #{exception}
  28. #{exception.backtrace.join("\n")}
  29. EOF
  30. Mailer.deliver email
  31. rescue
  32. end
  33. end
  34. end
  35. end
Add Comment
Please, Sign In to add comment