对于我的生活,我无法弄清楚如何使这项工作正常.
问题类似于其他人的问题,例如:如何滚动重启一群mongrels
但是,我们使用的是Nginx/Passenger而不是Mongrel.
如果我们使用此标准,问题是在部署时:重启任务:
task :restart, :roles => [:app], :except => {:no_release => true} do
run "cd #{deploy_to}/current && touch tmp/restart.txt"
end
Run Code Online (Sandbox Code Playgroud)
它触及每个Web服务器上的restart.txt文件,但是当前正在提供请求的任何乘客实例都需要在新的生成之前完成.这会造成严重的延迟并导致我们的应用程序在最多2分钟内无法使用,而所有内容都会重新启动.
为了解决这个问题,计划是做以下事情:
为了做到这一点,我尝试了这个:
(lb.txt是负载均衡器查找的文件)
task :restart, :roles => [:app], :except => {:no_release => true} do
servers = find_servers_for_task(current_task)
servers.map do |s|
run "cd #{deploy_to}/current && echo '' > public/lb.txt", :host => s.host
run %Q{rvmsudo /etc/init.d/nginx-passenger restart > /dev/null}, :host => s.host
sleep 60
run "cd #{deploy_to}/current && echo 'ok' …Run Code Online (Sandbox Code Playgroud)