I've been using a simple Capistrano recipe to deploy fixes to a production environment, and I figured hey, maybe other people want to do the same. I know there are other scripts out there, but this is particular to Ec2 on Rails and is tested against version 0.9.9.1.
Also, I've created a /stat page that responds with a 200 when the site is running. The recipe uses that url, but any other would work as well.
namespace :deploy do
desc "Hot deploy, only usable w/o migrations"
task :hot do
update
reroll
end
desc "Rolling restart for Mongrels"
task :reroll, :roles => :app_admin do
(8000..8005).each do |port|
sudo "monit -g app unmonitor mongrel_#{port}"
sudo "/usr/local/ec2onrails/bin/mongrel_stop --only #{port}"
sudo "/usr/local/ec2onrails/bin/mongrel_start --only #{port}"
sudo "wget --no-verbose localhost:#{port}/stat && rm -f stat" # this should block until the mongrel has booted
sudo "monit -g app monitor mongrel_#{port}"
end
end
end