[Rails] Capistrano와 seesaw를 이용해서 배포하기
capistrano는 rails application의 배포를 쉽게 해주고 - [Rails] Capistrano 2.0 을 사용해서 deployment 자동화하기 참조
seesaw는 서비스의 중단 없이 rails application을 재시작 할 수 있도록 해 준다. - seesaw 사용해서 서비스를 우아하게 재시작하기 참조
한걸음 더 나아가서 capistrano와 seesaw를 이용해서 서비스의 중단없이 rails application을 배포해보자.
capistrano의 deploy 명령은 소스를 svn으로부터 checkout 받고 적당한 symbolic link를 생성한 후 rails를 재시작한다. mongrel_cluster를 사용하고 있다면 이 재시작 명령이 다음과 같다.
- mongrel_rails cluster::restart
이것을 seesaw를 이용해서 재시작하는 다음 명령으로 바꾸면 되겠다.
- mongrel_rails seesaw::bounce
Capistrano의 restart task 재정의하기
config/deploy.rb 파일에 capistrano의 restart task를 재정의하자.
- set :seesaw_conf, "#{current_path}/config/seesaw.yml"
namespace :deploy do
desc <<-DESC
Restart the Mongrel processes on the app server using seesaw
DESC
task :restart, :roles => :app do
send(run_method, "#{mongrel_rails} seesaw::bounce -C #{seesaw_conf}")
end- end
만약 god를 사용해서 mongrel들을 감시하고 있다면 restart task를 다음과 같이 하자.
- task :restart, :roles => :app do
- send(run_method, "god unmonitor pichu")
- send(run_method, "sleep 5")
send(run_method, "#{mongrel_rails} seesaw::bounce -C #{seesaw_conf}") - send(run_method, "sleep 5")
- send(run_method, "god monitor pichu")
end
끝이다.
에러
cap deploy 중 mongrel_cluster.yml를 못찿겠다는 에러가 발생한다면 seesaw.yml의 mongrel_config_file을 절대경로로 바꾸어 주자.
mongrel_config_path가 아니고 mongrel_config_file이다.
- mongrel_config_file: /PATH/TO/RAILS/config/mongrel_cluster.yml
Comments (0)