Skip to content

Instantly share code, notes, and snippets.

@morika-t
Forked from jnewland/Capfile
Created September 27, 2013 06:20
Show Gist options
  • Save morika-t/6724768 to your computer and use it in GitHub Desktop.
Save morika-t/6724768 to your computer and use it in GitHub Desktop.
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
$ 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