Sha256: 46f3c0b5d8a1aae5c46facb8c006de0e51f3ef57dbdb70be0e13b7cd9d70de2b

Contents?: true

Size: 960 Bytes

Versions: 5

Compression:

Stored size: 960 Bytes

Contents

Capistrano::Configuration.instance(:must_exist).load do
  define_recipe :rolling_restart do
    
    # Define the rolling_restart task for mongrel
    namespace :mongrel do
      desc <<-DESC
      Do a rolling restart of mongrels, one app server at a time.
      DESC
      task :rolling_restart do
        find_servers(:roles => :app).each do |server|
          ENV['HOSTS'] = "#{server.host}:#{server.port}"
          nginx.stop
          puts "Waiting 10 seconds for mongrels to finish processing on #{ENV['HOSTS']}."
          sleep 10
          mongrel.restart
          puts "Waiting 60 seconds for mongrels to come back up on #{ENV['HOSTS']}."
          sleep 60
          nginx.start
        end
      end
    end
    
    # Use a rolling restart by default.  Theoretically, if we're doing migrations we should be using deploy:long anyway
    namespace :deploy do
      task :restart do
        mongrel.rolling_restart
      end
    end
    
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fdlcap-0.4.9 lib/fdlcap/recipes/rolling_restart.rb
fdlcap-0.4.7 lib/fdlcap/recipes/rolling_restart.rb
fdlcap-0.4.6 lib/fdlcap/recipes/rolling_restart.rb
fdlcap-0.4.5 lib/fdlcap/recipes/rolling_restart.rb
fdlcap-0.4.4 lib/fdlcap/recipes/rolling_restart.rb