Skip to content

Instantly share code, notes, and snippets.

@jagedn
Created July 15, 2016 11:40
Show Gist options
  • Save jagedn/ed08f182a3866680684fc01921941ba5 to your computer and use it in GitHub Desktop.
Save jagedn/ed08f182a3866680684fc01921941ba5 to your computer and use it in GitHub Desktop.
Use Gpars + Sshoogr to distribute a jar and execute it
@Grab('com.aestasit.infrastructure.sshoogr:sshoogr:0.9.25')
@Grab('org.codehaus.gpars:gpars:1.2.1')
@GrabConfig(systemClassLoader = true)
import static com.aestasit.infrastructure.ssh.DefaultSsh.*
import groovyx.gpars.GParsPool
options.trustUnknownHosts = true
stores = [ '10.0.1.1', '10.0.2.1', '10.0.3.1' ]
GParsPool.withPool(10) {
stores.eachParallel{ ip ->
remoteSession("user:pwd@${ip}") {
scp{
from { localFile "./dist/forecast.jar" }
into { remoteFile 'forecast.jar' }
}
exec( showOutput: true, command: 'java -jar forecast.jar' )
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment