First, consider why you want to do this. Parallel processing is an
optimization technique. Do you really need to optimize your deployment
process? Also, remember that parallelism introduces non-deterministic
behavior. Do you really want to complicate debugging your deployment
process?
> how do you solve this ?
Assuming that, yes, you really want to take on parallelizing your
deployment process, you need to look at threading. Capistrano is just Ruby,
which means you can use Ruby's threading support. This may or may not give
an advantage, given that Ruby uses green threads, but it's that or hacking
together a forking or pthreads C extension to run the commands, and I'm
assuming you don't want to do that. Of course, I don't know what global
state Capistrano keeps, so it may not be thread-safe.
> It would have been nice to have something lile:
> task :run_all do
> upload_app
> run_introducer || run_peers
> end
That is syntactically impossible. Remember that Capistrano is still Ruby.
The || operator means something specific, and cannot be redefined. You
could, however, do this (if Capistrano is thread-safe):
task :run_all do
upload_app
intro = Thread.new { run_introducer }
peers = Thread.new { run_peers }
intro.join
peers.join
end
I strongly recommend against trying to parallelize your deployment,
however. Simplicity and determinism are the cornerstones of a repeatable
deployment process.
--Greg
task :run_all do
upload_app
run "/path/to/run_introducer_and_peers.sh"
end
Capistrano will then invoke the shell script on all servers, and your
shell script can then fire off and manage those processes however you
want.
- Jamis
> --~--~---------~--~----~------------~-------~--~----~
> To unsubscribe from this group, send email to capistrano-...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/capistrano
> -~----------~----~----~----~------~----~------~--~---
>
Note, though, that Capistrano was _never_ intended as a replacement
for shell scripting. Underneath, everything cap does is shell
scripting. You give it a shell command and it executes it. Do not fear
shell scripting, embrace it! If you are avoiding shell scripts, you're
only taking advantage of about half of what cap can do for you.
- Jamis