2012-01-10 2 views
5

카피 스트라노를 3 대의 물리적 서버에 배치하도록 구성했습니다. 다시 시작 작업을 구성하여 각 서버로 순차적으로 이동하여 모든 서버로 동시에 이동하는 기본 방법이 아닌 응용 프로그램을 다시 시작하고 싶습니다.카피스트라 순차적 재시작

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 

어떤 아이디어를 여기

현재 배포 작업입니다?

답변

5

HOSTFILTER 환경 변수를 사용하면 필터와 일치하는 호스트에 대해 모든 것을 효과적으로 적용 할 수 있습니다.

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

같은

뭔가 트릭을 할해야합니다.