當進入網絡服務器時,我可以整天無延遲地重新啓動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)
更新:
閱讀周圍,現在看來,這可能是裏面有一個競爭條件做守護進程。不過,我有點困惑,爲什麼它在使用卡皮斯特拉諾時只顯示(並始終如一)。我會嘗試改變命令停止,然後開始睡覺。