【问题标题】:Configuring Exception Notification with Delayed Jobs in Rails 4在 Rails 4 中使用延迟作业配置异常通知
【发布时间】:2013-09-17 15:15:12
【问题描述】:

当延迟作业失败时,我无法让异常通知 gem 通知我。我可以让作业失败,但不会发出任何通知。其他人知道这个吗?

我正在使用:

delayed_job_active_record (4.0.0)
exception_notification (4.0.0)

并且在我的初始化程序/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

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-4 delayed-job exception-notification


    【解决方案1】:

    由于 exception_notification 4.0 there's a new way to handle manual notify。尝试改变

    ExceptionNotifier::Notifier.background_exception_notification(error)
    

    为

    ExceptionNotifier.notify_exception(error)
    

    【讨论】:

      猜你喜欢
      • 2011-05-05
      • 2013-09-17
      • 2013-11-26
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-08
      • 1970-01-01
      相关资源
      最近更新 更多