mercredi 10 mai 2017

Why won't the Delayed Job error callback execute?

I am trying to follow this guide about handling API rate limits with Delayed Job.

Here is my job:

# app/jobs/mailer_job.rb
class MailerJob < Struct.new(:custom_id)

  def perform
    # Intentionally throw an error to test error callback
    raise StandardError
  end

  def error(job, exception)
    puts 'Error!'
  end

end

Here are the potentially related gems I have installed. I am using Ruby 1.9.3.

gem 'rails', '3.0.20'
gem 'passenger', '5.0.21'
gem 'delayed_job_active_record', '4.1.1'
gem 'delayed_job', '4.1.2'
gem 'foreman', '0.83.0'

I see the following in the Delayed Job log:

[Worker(host:ubuntu pid:9912)] Starting job worker
[Worker(host:ubuntu pid:9912)] Job MailerJob (id=1720) RUNNING
[Worker(host:ubuntu pid:9912)] Job MailerJob (id=1720) FAILED (0 prior attempts) with StandardError: StandardError
[Worker(host:ubuntu pid:9912)] 1 jobs processed at 12.9574 j/s, 1 failed

I never see the error callback happen. However, if I kill the rails server with CTRL+C then it instantly prints the error callback puts statement.

Why do the error callbacks on the custom Delayed Job not execute while the server is running?

Aucun commentaire:

Enregistrer un commentaire