Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delayed job wont start using Capistrano

I cannot start delayed job process using a capistrano recipe. Here's the error I am getting.

/usr/local/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.1/lib/delayed/command.rb:62:in `mkdir': File exists - /my_app/server/releases/20101120001612/tmp/pids (Errno::EEXIST)

Here's the capistrano code (NOTE-: I have tried both start/restart commands)

after "deploy:restart", "delayed_job:start"
task :start, :roles => :app do          
  run "cd #{current_path}; RAILS_ENV=#{rails_env} script/delayed_job -n 2 start"
end

More detail errors from deployment logs -

executing command
 [err :: my_server] /usr/local/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.1/lib/delayed/command.rb:62:in `mkdir': File exists - /my_app/server/releases/20101120001612/tmp/pids (Errno::EEXIST)
 [err :: my_server] from /usr/local/lib/ruby/gems/1.9.1/gems/delayed_job-2.1.1/lib/delayed/command.rb:62:in `daemonize'
 [err :: my_server] from script/delayed_job:5:in `<main>'
    command finished
failed: "sh -c 'cd /my_app/server/current; RAILS_ENV=production script/delayed_job -n 3 restart'" on myserevr

This is a Rails 3 app (v3.0.3)

like image 687
kapso Avatar asked Nov 20 '10 00:11

kapso


2 Answers

Seeing the same problem.

It turns out I was missing the ~/apps/application_name/shared/pids directory.

Finally creating it made this problem go away.

No need to set up custom dj_pids directory.

like image 89
ranktrackerpro Avatar answered Oct 06 '22 13:10

ranktrackerpro


I also got this error and found a couple of issues:

  • Ensure you have a shared/pids folder.
  • Ensure you have the correct hooks setup

Your deploy.rb script should contain:

require "delayed/recipes"

after "deploy:stop", "delayed_job:stop"
after "deploy:start", "delayed_job:start"
after "deploy:restart", "delayed_job:restart"

I'd copied the hooks from an old post and they appear to be incorrect now. These are from the actual delayed_job recipe file comments.

I believe cap deploy:setup should create the pids folder but I set things up a different way and it was not created. app/current/tmp/pids links to app/shared/pids and this was causing the false directory exists error.

like image 39
PhilT Avatar answered Oct 06 '22 12:10

PhilT