【问题标题】:capistrano sequential restartscapistrano 顺序重启
【发布时间】:2012-01-10 20:50:34
【问题描述】:

我已将 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

我在想这样的事情:

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

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails capistrano


    【解决方案1】:

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

    类似

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

    应该可以解决问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 2013-12-04
      • 1970-01-01
      • 2016-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多