Created
August 22, 2010 20:39
-
-
Save jnewland/544259 to your computer and use it in GitHub Desktop.
execute capistrano commands serially
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server 'localhost', :test | |
server '127.0.0.1', :test2 | |
task :test_serially do | |
serially do | |
run 'date && sleep 5' | |
end | |
end | |
def serially(&block) | |
original = ENV['HOSTS'] | |
find_servers_for_task(self.current_task).each do |server| | |
ENV['HOSTS'] = server.host | |
yield | |
end | |
ensure | |
ENV['HOSTS'] = original | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cap test_serially | |
* executing `test_serially' | |
* executing "date && sleep 5" | |
servers: ["localhost"] | |
[localhost] executing command | |
** [out :: localhost] Sun Aug 22 16:38:45 EDT 2010 | |
command finished | |
* executing "date && sleep 5" | |
servers: ["127.0.0.1"] | |
[127.0.0.1] executing command | |
** [out :: 127.0.0.1] Sun Aug 22 16:38:51 EDT 2010 | |
command finished |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice!