I have been running delayed_job and was hitting some errors, but now I don’t know what is sitting in the job queue or what’s going on with them….
How can I figure that out so I can debug whether it is able to execute what has been put in the queue?
Here is where I call the job (it is part of a cron task) and the mailer it calls:
class SomeMailJob < Struct.new(:contact, :contact_email)
def perform
OutboundMailer.deliver_campaign_email(contact,contact_email)
end
end
#class OutboundMailer < ActionMailer::Base
class OutboundMailer < Postage::Mailer
def campaign_email(contact,email)
subject email.subject
recipients contact.email
from 'Timothy Fong <tim.fong@opshub.com>'
sent_on Date.today
body :email => email
end
You can gain insight into your delayed_job queue through the Delayed::Job model (I think the name of it might have changed in later versions). It’s just an ActiveRecord model and you can do all the things you’d do to a normal one. Find all, find ones with
failed_atset, find ones withlocked_byset (currently being worked).I find they’re much easier to read if you to_yaml them first:
y Delayed::Job.allfrom console.