Data-AnyXfer
view release on metacpan or search on metacpan
lib/Data/AnyXfer/Elastic/Import/SpawnTask/Remote.pm view on Meta::CPAN
my $remote_host = $args{remote_host_instance};
# prepare rsync arguments
my @rsync_cmd = (
Core::Path::Utils->rsync, #
'-a', # archive mode,
'-v', # verbose
'-q', # keep partial files, show progress
'--no-p', # don't preserve permissions
'--no-g', # don't preserve groups
'--chmod=ugo=rwX', #
);
my $remote_target = sprintf '%s:%s', $remote_host->host,
$args{remote_target};
# add optional arguments
if ( my $user = $remote_host->user ) {
$remote_target = $user . '@' . $remote_target;
}
lib/Data/AnyXfer/Elastic/Import/SpawnTask/Remote.pm view on Meta::CPAN
"#!/usr/bin/env bash\n" . $command
# XXX : sleep here so that execution
# cannot finish between starting the remote command and detecting
# the PID (pretty hard to happen, but theoretically could)
. "\nsleep 5"
);
# move the command file to the remote host
$command_file = $class->_remote_transfer_object( $command_file, $args );
# (and make it user executable)
$remote_host->run( 1, qq!chmod u+x $command_file! );
# spawn a background process running on the remote host
$remote_host->run( 0, qq/screen -d -m $command_file/ );
# find the PID of the remote command
my $pid = $remote_host->run( 0, qq!pgrep -f "$command_file"! );
$pid = ( $pid =~ /^(\d+)/ )[0];
# if the command has finished already, we should probably bail
# as it likely didn't execute
( run in 0.279 second using v1.01-cache-2.11-cpan-8d75d55dd25 )