Search code examples
ruby-on-railsdelayed-job

delayed_job works only with rake jobs:workoff, not with RAILS_ENV=production bin/delayed_job start


I have pretty simple task - I need to check if submission was assigned to developer within 2 minutes after it was created. And if not, send an email notifying about it.

App written in Rails4. I decided to use delayed_job gem.

after_create :unassigned_submission_pending_notification
def unassigned_submission_pending_notification 
  NotificationMailer.unassigned_submissions_pending(self).deliver if developer_id.nil?
end
  handle_asynchronously :unassigned_submission_pending_notification, run_at: Proc.new { 2.minutes.from_now }

In documentation it is said to run RAILS_ENV=production bin/delayed_job start to make a worker do his job. But in my case this command do nothing, and only when I run rake jobs:workoff it works.

Any thoughts why?

Thank you!


Solution

  • You can try like this:

    RAILS_ENV=production bundle exec bin/delayed_job start
    

    Or this:

    rake jobs:work