Parallel execution of ssh commands on multiple hosts
matthiasbalke opened this issue · comments
We do our server deployment with the gradle-ssh-plugin
. It is running perfectly fine, but we wan't to speed it up by executing some commands in parallel on multiple hosts.
Is it possible? Down below is an example on how I imagine to use it.
today
ssh.run {
session(remotes.allRoles('tomcat', stage)) {
execute "echo 'starting deployment ...'"
execute "${sudo_prefix} deploy.sh"
}
}
parallel
ssh.run {
parallelSession(remotes.allRoles('tomcat', stage)) {
execute "echo 'starting deployment ...'"
execute "${sudo_prefix} deploy.sh"
}
}
Use executeBackground
to run commands in parallel.
ssh.run {
session(remotes.allRoles('tomcat', stage)) {
executeBackground "echo 'starting deployment ...'"
executeBackground "${sudo_prefix} deploy.sh"
}
}
I think this behavior is confusing and parallelSession
is intuitive. It will be improved in the next major release.
Awesome, I didn't know about executeBackground
, I will try it.
After testing executeBackground
I realized that it is not doing what I intended to do.
I wanted to execute a serial block, parallel on multiple hosts. As far as I understand, I cannot configure this using executeBackground
.
At this moment session
blocks are executed in serial because parallel execution needs complex implementation on Java 6.
In the release 2.7.0, Java 6 support will be removed and session
blocks will be executed in parallel using ForkJoinPool
.
@int128 Today I tested the parallel execution with 2.7.0
. It seems to work, but I'm wondering why I do not get the expected performance boost. I will figure it out for my concrete problem. From my side everything I needed was released with 2.7.0
and this issue can be closed.