Reputation: 12066
I can't get the Exception Notification gem to notify me when a Delayed Job fails. I can have jobs fail, but no notification is going out. Anyone else figured this out?
I'm using:
delayed_job_active_record (4.0.0)
exception_notification (4.0.0)
And have the following in my initializers/delayed_jobs_config:
# Chain delayed job's handle_failed_job method to do exception notification
Delayed::Worker.class_eval do
def handle_failed_job_with_notification(job, error)
handle_failed_job_without_notification(job, error)
# only actually send mail in production
if Rails.env.production?
# rescue if ExceptionNotifier fails for some reason
begin
ExceptionNotifier::Notifier.background_exception_notification(error)
rescue Exception => e
Rails.logger.error "ExceptionNotifier failed: #{e.class.name}: #{e.message}"
e.backtrace.each do |f|
Rails.logger.error " #{f}"
end
Rails.logger.flush
end
end
end
alias_method_chain :handle_failed_job, :notification
end
Upvotes: 2
Views: 2076
Reputation: 12540
Since exception_notification 4.0 there's a new way to handle manual notify. Try to change
ExceptionNotifier::Notifier.background_exception_notification(error)
for
ExceptionNotifier.notify_exception(error)
Upvotes: 3