How do i integrate Hoptoad with DelayedJob and DaemonSpawn?

后端 未结 4 1799
渐次进展
渐次进展 2021-02-06 13:13

I have been happily using the DelayedJob idiom:

foo.send_later(:bar)

This calls the method bar on the object foo in the DelayedJob process.

4条回答
  •  生来不讨喜
    2021-02-06 13:34

    Try monkeypatching Delayed::Worker#handle_failed_job :

    # lib/delayed_job_airbrake.rb
    
    module Delayed
      class Worker
    
        protected
    
        def handle_failed_job_with_airbrake(job, error)
          say "Delayed job failed -- logging to Airbrake"
          HoptoadNotifier.notify(error)
          handle_failed_job_without_airbrake(job, error)
        end
    
        alias_method_chain :handle_failed_job, :airbrake
    
      end
    end
    

    This worked for me.

    (in a Rails 3.0.10 app using delayed_job 2.1.4 and hoptoad_notifier 2.4.11)

提交回复
热议问题