Skip to content

Instantly share code, notes, and snippets.

@imbriaco
Created February 9, 2009 16:28
Show Gist options
  • Save imbriaco/60855 to your computer and use it in GitHub Desktop.
Save imbriaco/60855 to your computer and use it in GitHub Desktop.
desc "Do rolling restarts of the Mongrel servers in pairs, at 90s intervals."
task :rolling do
servers = []
roles[:app].each do |server|
next unless server.options.fetch(:listener, true)
servers << [] if servers.first.nil? || servers.last.length > 1
servers.last << server.host
end
servers.each_with_index do |hosts, index|
restart_hosts = hosts.join(',')
puts "Restarting hosts on #{restart_hosts}"
ENV['HOSTS'] = restart_hosts
deploy.restart
if index + 1 < servers.length
puts 'Pausing 30 seconds for servers to cool down.'
sleep 30
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment