Skip to content

Instantly share code, notes, and snippets.

@trevorh
Forked from sudara/restarts.rb
Created February 9, 2010 14:54
Show Gist options
  • Save trevorh/299268 to your computer and use it in GitHub Desktop.
Save trevorh/299268 to your computer and use it in GitHub Desktop.
set :mongrel_rolling_restart_delay, 55
namespace :mongrel do
desc <<-DESC
Start mongrels in a loop, with a defer of [default] 30 seconds between each single mongrel restart. mongrel_rolling_restart_delay can be set to override the default.
DESC
task :rolling_restart, :roles => [:app], :except => {:mongrel => false} do
set(:restart_delay) { fetch(:mongrel_rolling_restart_delay, 30) }
run %{
for mongrel in $(#{sudo} monit summary | grep -o -E mongrel_#{monit_group}_[0-9]+); \
do \
echo "Executing monit restart ${mongrel}"; \
#{sudo} /usr/bin/monit restart ${mongrel}; \
echo "sleeping #{restart_delay}"; \
sleep #{restart_delay}; \
done
}
puts "Done."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment