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 7604399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:53:58+00:00 2026-05-30T23:53:58+00:00

When sshing into the webserver I can restart delayed_job all day without a problem.

  • 0

When sshing into the webserver I can restart delayed_job all day without a problem. It brings down the existing worker, starts a new one and writes tmp/pids/delayed_job.pid with its process id. (I am also restarting passenger to mimic what I’m about to do with capistrano)

app@StagingServer:/app/current$ touch tmp/restart.txt; RAILS_ENV=staging script/delayed_job restart
delayed_job: trying to stop process with pid 22170...
delayed_job: process with pid 22170 successfully stopped.
delayed_job: process with pid 22284 started.
app@StagingServer:/app/current$ touch tmp/restart.txt; RAILS_ENV=staging script/delayed_job restart
delayed_job: trying to stop process with pid 22284...
delayed_job: process with pid 22284 successfully stopped.
delayed_job: process with pid 22355 started.
app@StagingServer:/app/current$ touch tmp/restart.txt; RAILS_ENV=staging script/delayed_job restart
delayed_job: trying to stop process with pid 22355...
delayed_job: process with pid 22355 successfully stopped.
delayed_job: process with pid 22427 started.
app@StagingServer:/app/current$

However, when I deploy using capistrano

dev@ubuntu:~/app-site$ cap passenger:restart
    triggering start callbacks for `passenger:restart'
  * executing `multistage:ensure'
*** Defaulting to `staging'
  * executing `staging'
  * executing `passenger:restart'
  * executing "touch /app/current/tmp/restart.txt"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
    command finished in 242ms
  * executing "cd /app/current;RAILS_ENV=staging script/delayed_job restart"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
 ** [out :: staging.app.com] delayed_job: trying to stop process with pid 21646...
 ** [out :: staging.app.com] delayed_job: process with pid 21646 successfully stopped.
    command finished in 11889ms

Seems fine? While the last line from delayed_job isn’t printed (I think due to it not ending in a newline) this does successfully create a new process. However, it doesn’t create the .pid file, so when I try and restart again:

dev@ubuntu:~/app-site$ cap passenger:restart
    triggering start callbacks for `passenger:restart'
  * executing `multistage:ensure'
*** Defaulting to `staging'
  * executing `staging'
  * executing `passenger:restart'
  * executing "touch /app/current/tmp/restart.txt"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
    command finished in 398ms
  * executing "cd /app/current;RAILS_ENV=staging script/delayed_job restart"
    servers: ["staging.app.com"]
    [staging.app.com] executing command
 ** [out :: staging.app.com] Warning: no instances running. Starting...
 ** [out :: staging.app.com] delayed_job: process with pid 21950 started.
    command finished in 6758ms

It doesn’t stop the existing process. Strangely, this time it will create a new process and it’s .pid file.

This leaves me with 2 delayed_jobs processes running and only one in the .pid file. Every 2 cap deploys I do will add another delayed_job process. The previous processes are using the old version of the app, essentially breaking it.

config/deploy.rb:

namespace :passenger do
  desc "Restart Application"  
  task :restart do  
    run "touch #{current_path}/tmp/restart.txt"
    run "cd #{current_path};RAILS_ENV=#{deploy_env} script/delayed_job restart"
  end
end
after :deploy, "passenger:restart"
  • Ubuntu, nginx, passenger
  • daemons (1.1.4)
  • delayed_job (2.1.4)
  • rails (3.0.9)

And locally

  • capistrano (2.9.0)
  • capistrano-ext (1.2.1)

Update:

Reading around, it seems it could be to do with a race condition inside daemons. However I’m a bit confused why it’s showing only (and consistently) when using capistrano. I will try changing the command to a stop, sleep then start.

  • 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-30T23:54:00+00:00Added an answer on May 30, 2026 at 11:54 pm

    Solved by using stop and start instead of restart. Works due to a race condition probably caused by the daemons gem.

    I would still like to know if anyone else has a better solution.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently, I use PuTTY for SSHing into my linux server and Cygwin for local
I'm automating web-UI testing using Selenium. All our existing non-UI related tests are executed
I have a work machine that I can access by sshing twice, once to
I'm frequently sshing into a server, switching to a specific directory and running svn-update
i have a php script which runs fine when executed by SSHing into my
When I SSH into an Amazon instance without an elastic IP I use the
everyday I encounter a very strange phenomenon. From my university internet connection, sshing to
By default, when SSH'ing into a client I am automatically placed into /home/marco/ but
In order to debug failing requests I would like to print all information coming
On my Linux platform with 64bits recompiled perl and SSHing Mac terminal (I guess

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.