延迟工作不会开始使用Capistrano

kap*_*pso 10 capistrano ruby-on-rails delayed-job

我无法使用capistrano配方启动延迟的工作流程.这是我得到的错误.

/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)
Run Code Online (Sandbox Code Playgroud)

这是capistrano代码(注意:我已经尝试了两个启动/重启命令)

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
Run Code Online (Sandbox Code Playgroud)

部署日志中的更多细节错误 -

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
Run Code Online (Sandbox Code Playgroud)

这是一个Rails 3应用程序(v3.0.3)

小智 21

看到同样的问题.

事实证明我错过了~/apps/application_name/shared/pids目录.

最后创建它使这个问题消失了.

无需设置自定义dj_pids目录.


Phi*_*ilT 10

我也遇到了这个错误并发现了一些问题:

  • 确保您有一个shared/pids文件夹.
  • 确保您具有正确的挂钩设置

您的deploy.rb脚本应包含:

require "delayed/recipes"

after "deploy:stop", "delayed_job:stop"
after "deploy:start", "delayed_job:start"
after "deploy:restart", "delayed_job:restart"
Run Code Online (Sandbox Code Playgroud)

我复制了旧帖子中的钩子,现在看起来不正确.这些来自实际的delayed_job配方文件注释.

我相信cap deploy:setup应该创建pids文件夹,但我设置了一个不同的方式,它没有创建.app/current/tmp/pids链接到app/shared/pids这导致了错误的目录存在错误.


kap*_*pso 4

这就是我解决问题的方法,我使用“--pid-dir”传递了显式的 pids dir 参数。不确定这是否完美,但它确实有效。

task :restart, :roles => :app do
  run "cd #{current_path}; RAILS_ENV=#{rails_env} script/delayed_job -n #{dj_proc_count} --pid-dir=#{app_root}/shared/dj_pids restart"
end
Run Code Online (Sandbox Code Playgroud)