@@ -3,6 +3,7 @@ use rand::rngs::StdRng;
3
3
use rand:: RngCore ;
4
4
use rand:: SeedableRng ;
5
5
use rand_xorshift:: XorShiftRng ;
6
+ use std:: path:: PathBuf ;
6
7
use std:: { convert:: TryFrom , time:: Duration } ;
7
8
use std:: { fmt:: Debug , time:: Instant } ;
8
9
@@ -227,6 +228,39 @@ impl Config {
227
228
{
228
229
if self . hosts . is_some ( ) && self . process_id . is_none ( ) {
229
230
let exec = std:: env:: args ( ) . nth ( 0 ) . unwrap ( ) ;
231
+ // first, we copy the executable to a known location, so that then we can run it
232
+ let remote_exec = PathBuf :: from ( "/tmp" ) . join (
233
+ PathBuf :: from ( & exec)
234
+ . file_name ( )
235
+ . unwrap_or_else ( || panic ! ( "cannot get file name for {}" , exec) )
236
+ ) ;
237
+ println ! ( "Copying the executable to minions" ) ;
238
+ let handles: Vec < std:: process:: Child > = self
239
+ . hosts
240
+ . as_ref ( )
241
+ . unwrap ( )
242
+ . hosts
243
+ . iter ( )
244
+ . map ( |host| {
245
+ let dest = format ! (
246
+ "{}:{}" ,
247
+ host. name,
248
+ remote_exec. to_str( ) . expect( "cannot convert path to string" )
249
+ ) ;
250
+ Command :: new ( "rsync" )
251
+ . arg ( "--progress" )
252
+ . arg ( & exec)
253
+ . arg ( dest)
254
+ . spawn ( )
255
+ . expect ( "problem spawning the rsync process" )
256
+ } )
257
+ . collect ( ) ;
258
+
259
+ for mut h in handles {
260
+ h. wait ( ) . expect ( "problem waiting for the rsync process" ) ;
261
+ }
262
+
263
+
230
264
info ! ( "spawning executable {:?}" , exec) ;
231
265
// This is the top level invocation, which should spawn the processes with ssh
232
266
let mut handles: Vec < std:: process:: Child > = self
@@ -241,7 +275,7 @@ impl Config {
241
275
info ! ( "Connecting to {}" , host. name) ;
242
276
Command :: new ( "ssh" )
243
277
. arg ( & host. name )
244
- . arg ( & exec )
278
+ . arg ( & remote_exec )
245
279
. arg ( encoded_config)
246
280
. spawn ( )
247
281
. expect ( "problem spawning the ssh process" )
0 commit comments