Zac*_*c M 2 capistrano ruby-on-rails delayed-job ruby-on-rails-3
当sshing进入网络服务器时,我可以整天重启delayed_job而不会出现问题.它会关闭现有的worker,启动一个新的worker并将tmp/pids/delayed_job.pid写入其进程ID.(我也在重新启动乘客以模仿我将要使用的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$
Run Code Online (Sandbox Code Playgroud)
但是,当我使用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
Run Code Online (Sandbox Code Playgroud)
好像不错?虽然不打印delayed_job的最后一行(我认为由于它没有以换行结尾),但这确实成功地创建了一个新进程.但是,它不会创建.pid文件,因此当我尝试重新启动时:
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
Run Code Online (Sandbox Code Playgroud)
它不会阻止现有流程.奇怪的是,这次它将创建一个新进程,它是.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"
Run Code Online (Sandbox Code Playgroud)
在当地
更新:
阅读,似乎可能与守护进程内的竞争条件有关.但是我有点困惑为什么它在使用capistrano时只显示(并且始终如一).我会尝试将命令更改为停止,然后睡眠然后启动.
| 归档时间: |
|
| 查看次数: |
1830 次 |
| 最近记录: |