I am using Capistrano to manage a Java web app that is running on several load balanced servers. Certain tasks (such as config changes) require a server restart, or app redeploy, during which the server becomes non-responsive.
If Capistrano could perform these tasks on servers consecutively, vs. concurrently, only one machine in the farm would go down at a time, and the load balancer would ensure that no requests are lost. However, from what I can tell, Capistrano only performs operations on servers concurrently.
To be clear, I'm not trying to execute different tasks consecutively. I'm trying to execute the same task on different servers consecutively.
I can think of some ways of hacking this in my configuration, but it seems like there should be a flag I can set somewhere.
Anybody know how to do this?
For people who ends up in this page nowadays: You can use
in: :sequence
as described at http://capistranorb.com/2013/06/01/release-announcement.htmlYou can set
:max_hosts
for the task to limit its parallelism::max_hosts
- specifies the maximum number of hosts that should be selected at a time. If this value is less than the number of hosts that are selected to run, then the hosts will be run in groups of max_hosts. The default is nil, which indicates that there is no maximum host limit. Please note this does not limit the number of SSH channels that can be open, only the number of hosts upon which this will be called.Example:
Capistrano 3 uses SSHKit which provides for sequential sending of commands to multiple servers. There's an example on the SSHKit read me:
https://github.com/capistrano/sshkit
Note, Capistrano 3 is quite a change from Capistrano 2.x.
I use this to restart my servers in series, instead of in parallel:
Hi it does not seam possible in capistrano easily, of course some approaches can be taken.
1) you could specify each server in different role and add a separate task responsible for rotation of roles and calling the task that does actually required task.
2) you could write separate script doing rotation as above but using different host names instead of roles
3) it is also possible to filter hostnames/servers in capistrano using environment variable, maybe you could use it in in rotation algorithm.
Unfortunately there s no good documentation for capistrano for me reading capistrano sources worked quite well but it takes also a lot of time.