Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:37:25+00:00 2026-05-24T09:37:25+00:00

I am using Ruby on Rails 3.0.9 and I am trying to setup the

  • 0

I am using Ruby on Rails 3.0.9 and I am trying to setup the delay_job gem. All works if, after rebooting the Apache2 server, I run in the Terminal\Console following commands:

RAILS_ENV=development script/delayed_job stop
RAILS_ENV=development script/delayed_job -n 2 start

However, since I always want to start the workers on application start, in my config/initializers/delayed_job.rb I add the following code (that handles both development and production mode):

if Rails.env.development?
  system 'RAILS_ENV=development script/delayed_job stop'
  system 'RAILS_ENV=development script/delayed_job -n 2 start'
elsif Rails.env.production?
  system 'RAILS_ENV=production script/delayed_job stop'
  system 'RAILS_ENV=production script/delayed_job -n 2 start'
end

However, by using the above code and after re-rebooting the Apache2 server, the DJ gem doesn’t work anymore as expected. That is, it doesn’t process jobs as it makes when I run the above command lines in the Terminal\Console.

How can I make DJ to work correctly? What is the problem?

P.S.: I would like to do that in order to automatize processes.


It seams that the above code in the config/initializers/delayed_job.rb file doesn’t “create” the “pids” files related to DJ in the RAILS_ROOT/tmp/pids directory. Those are created only by running the above command lines manually. Why this happens?


UPDATE for @Devin M

My config/initializers/delayed_job.rb contains:

# Options
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.sleep_delay = 2
Delayed::Worker.max_attempts = 5
Delayed::Worker.max_run_time = 1.hour
Delayed::Worker.delay_jobs = !Rails.env.test?

if Rails.env.development?
  system "RAILS_ENV=development #{Rails.root.join('script','delayed_job')} stop"
  system "RAILS_ENV=development #{Rails.root.join('script','delayed_job')} -n 2 start"
elsif 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"
end
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:37:27+00:00Added an answer on May 24, 2026 at 9:37 am

    Try using this code:

    system "RAILS_ENV=production #{Rails.root.join('script','delayed_job')} stop"
    system "RAILS_ENV=production #{Rails.root.join('script','delayed_job')} -n 2 start"
    

    Testing it in the console produced this output which indicates it should work:

    Loading development environment (Rails 3.0.9)
    ruby-1.9.2-p290 :001 > Rails.root.join('script','delayed_job')
     => #<Pathname:/home/devin/testsoapp/script/delayed_job> 
    ruby-1.9.2-p290 :002 > "RAILS_ENV=production #{Rails.root.join('script','delayed_job')} -n 2 start"
     => "RAILS_ENV=production /home/devin/testsoapp/script/delayed_job -n 2 start" 
    ruby-1.9.2-p290 :003 > 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When trying to launch the rails console after updating my ruby setup using 'sudo
I'm trying to use setup the rails application on apache2 using the virtual server
I'm trying to setup an automated build server for my rails projects using Hudson
I am using rails 3.0.3, ruby 1.9.2-p180, mail (2.2.13). I m trying to setup
I'm trying to run a rails 3 app on a windows server using jruby
I'm trying to run a rails 3 app on a windows server using jruby
I am using Ruby on Rails 3.0.9 and I am trying to setup the
I'm trying to write an app using Ruby on Rails and I'm trying to
I'm trying to build a web service using Ruby on Rails. Users authenticate themselves
I am trying to set up Ruby on Rails on windows. I am using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.