2012-01-10 7 views
5

カプリストラを3台の物理サーバーに展開するように構成しました。私はすべてのサーバーに一度に行くデフォルトの方法ではなく、順番に各サーバーに移動し、アプリケーションを再起動する再起動タスクを構成したいと思います。カピストラー順次再起動

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

任意のアイデア:

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 

私はこのような何かを考えています。ここでは

は、現在のdeployタスクのですか?

答えて

5

私は効果的にフィルタに一致するホストにすべてをスコープHOSTFILTER環境変数を使用して、非常に似た何かをします。

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

よう

何かがトリックを行う必要があります。