Initializers file not working for delayed_job on rails app

379 views
Skip to first unread message

BHAVIK Housing

unread,
Oct 9, 2015, 9:18:13 AM10/9/15
to delayed_job, Ankur Kumar, Kailash Bagaria, Vaibhav Gupta, BHAVIK Housing
Hi, kindly help me find a solution for the issues i am facing with delayed_job :-
this is my initializers file:

# config/initializers/delayed_job_config.rb

Delayed::Worker.sleep_delay = 3
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.max_attempts = 3
Delayed::Worker.max_run_time = 5.minutes
Delayed::Worker.read_ahead = 10
Delayed::Worker.default_queue_name = 'default'
Delayed::Worker.delay_jobs = !Rails.env.test?


if Rails.env.production?
  system "RAILS_ENV=production #{Rails.root.join('script','delayed_job')} stop"
  system "RAILS_ENV=production #{Rails.root.join('script','delayed_job')} -n 2 start"
else
  # system "RAILS_ENV=development #{Rails.root.join('script','delayed_job')} stop"
  # system "RAILS_ENV=development #{Rails.root.join('script','delayed_job')} -n 2 start"
end


There are multiple issues that i am facing with the delayed_job config file:

1.Jobs are getting deleted after 1 failure only which ideally should not get deleted at all as seen from above config file at least there must be 3 attempts.
2. Also i have to run RAILS_ENV=production script/delayed_job stop , RAILS_ENV=production script/delayed_job -n 2 start  manually which again should run from config  file itself.
3. Timeout::Error: execution expired  message for the failed jobs.(there is no heavy jobs yet it is showing this error which i believe may be misleading)


Rails version:- 3.2.15  Ruby version:- ruby 1.9.3p551  OS version: Linux version 3.14.48-33.39.amzn1.x86_64 (mockbuild@gobi-build-60007) (gcc version 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) )  

Gem Versions:-

daemons1.1.9
delayed_job4.0.0
delayed_job_active_record4.0.0

Note:- While running in development environment none of the above issues exist but on production environment  issues occur.

Any help would be appreciated to find the cause of these issues.(already googled a lot but yet to find the working solution)

Thanks



David Genord II

unread,
Oct 9, 2015, 10:13:50 AM10/9/15
to delay...@googlegroups.com
Don't do that. When delayed_job starts it initializes your app. So that initializer gets run every time DJ starts, and the first thing DJ does is stop itself. Those commands should be in a deploy script, not in your application.

I would guess the rest sorts itself out, if you fix your deploy.

David

--

---
You received this message because you are subscribed to the Google Groups "delayed_job" group.
To unsubscribe from this group and stop receiving emails from it, send an email to delayed_job...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages