rares (owner)

Fork Of

Revisions

gist: 60858 Download_button fork
public
Public Clone URL: git://gist.github.com/60858.git
Embed All Files: show embed
Text only #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    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