当进入网络服务器时,我可以整天无延迟地重新启动delayed_job。它会关闭现有的工作人员,启动一个新的工作人员,并使用其进程ID写入tmp/pids/delayed_job.pid。 (我也重新开始载客模仿什么,我大约用Capistrano的做)当用capistrano重新启动delayed_job时,它并不总是创建pid文件
[email protected]:/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.
[email protected]:/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.
[email protected]:/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.
[email protected]:/app/current$
然而,当我部署使用Capistrano的
[email protected]:~/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
似乎罚款?虽然delayed_job的最后一行没有打印出来(我认为是因为它没有以换行符结尾),但它确实成功地创建了一个新进程。然而,它不会创建.pid文件,所以当我尝试并重新启动:
[email protected]:~/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
它不会停止现有的流程。奇怪的是,这次它会创建一个新的进程和它是.pid文件。
这让我有2个delayed_jobs进程正在运行,只有一个在.pid文件中。每做2个帽子部署,我都会添加另一个delayed_job进程。以前的流程使用旧版本的应用程序,基本上打破了它。
配置/ 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的,乘客
- 守护程序(1.1.4)
- delayed_job的(2.1.4)
- 轨(3.0.9 )
and local
- Capistrano的(2.9.0)
- Capistrano的-EXT(1.2.1)
更新:
阅读周围,现在看来,这可能是里面有一个竞争条件做守护进程。不过,我有点困惑,为什么它在使用卡皮斯特拉诺时只显示(并始终如一)。我会尝试改变命令停止,然后开始睡觉。