capistrano顺序重启

Aar*_*oir 5 capistrano ruby-on-rails

我将capistrano配置为跨三个物理服务器进行部署.我想配置重启任务以顺序转到每个服务器并重新启动应用程序,而不是一次性转到所有服务器的默认方式.

这是当前的部署任务:

namespace :deploy do

  task :start, :roles => :app, :except => { :no_release => true } do 
    run "cd #{current_path} && bundle exec unicorn_rails -c #{current_path}/config/unicorn.rb -E #{rails_env} -D"
  end

  task :stop, :roles => :app, :except => { :no_release => true } do 
    run "kill `cat #{current_path}/tmp/pids/unicorn.pid`"
  end

  task :restart, :roles => :app, :except => { :no_release => true } do
    stop
    sleep(10)
    start
  end

end
Run Code Online (Sandbox Code Playgroud)

我在想这样的事情:

#this does not work 
task :sequential_restart do
   find_servers(:roles => :app).each
    restart
   end
 end
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

Fre*_*ung 5

我使用HOSTFILTER环境变量做了一些非常相似的事情,它有效地将所有内容限定在与过滤器匹配的主机上.

就像是

find_servers(:roles => :app).each do |server|
  ENV['HOSTFILTER'] = server.host
  restart
end
ENV['HOSTFILTER'] = nil
Run Code Online (Sandbox Code Playgroud)

应该做的伎俩.