Delayed Job changing job parameters in Rails

Delayed job variables initialization written on at collectiveidea/delayed_job doesn’t work.

# config/initializers/delayed_job_config.rb
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 60
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 5.minutes

Here is the correct way of doing it as mentioned with tobi/delayed_job

# config/initializers/delayed_job_config.rb
  Delayed::Job.destroy_failed_jobs = false
  silence_warnings do
    Delayed::Job.const_set("MAX_ATTEMPTS", 3)
    Delayed::Job.const_set("MAX_RUN_TIME", 5.minutes)
  end

Advertisements

About sandipransing

Web Developer #ruby #rails #JS
This entry was posted in Ruby on Rails and tagged . Bookmark the permalink.

2 Responses to Delayed Job changing job parameters in Rails

  1. Christoph says:

    With the delayed_job branch from collectiveida it works perfectly with Delayed::Worker.xxxx
    Make sure you have version 2.x installed.

  2. Sanjeev Mishra says:

    Christoph is absolutely right…..

    I was configuring the delayed job and I got problems like :

    `method_missing_without_paginate’: undefined method `destroy_failed_jobs=’

    This is because I have 2.0.3 version of delayed job… The configuration parameters have all been moved to Delayed::Worker now and thus the following works for version 2.x:

    Delayed::Worker.destroy_failed_jobs = false
    Delayed::Worker.sleep_delay = 60
    Delayed::Worker.max_attempts = 3
    Delayed::Worker.max_run_time = 5.minutes

    or the following:

    Delayed::Worker.destroy_failed_jobs = false
    silence_warnings do
    Delayed::Worker.const_set(“MAX_ATTEMPTS”, 3)
    Delayed::Worker.const_set(“MAX_RUN_TIME”, 5.minutes)
    end

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s