Skip to content

Commit

Permalink
Add command "clusterd push files..."
Browse files Browse the repository at this point in the history
The command "clusterd push file..." has a new syntax with a command
verb. (as opposed to "clusterd --push file")

The push command is distributed via the area routers to the cluster
daemons on all nodes. It is intended that the cluster daemons call
back over tcp to the originator to pull the file if needed.
  • Loading branch information
donald committed Dec 7, 2017
1 parent 676ca6d commit 305be8a
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion clusterd
Original file line number Diff line number Diff line change
Expand Up @@ -1667,6 +1667,22 @@ sub cmd_msg {
}
}

sub cmd_push {
my @files=@_;
for my $filename (@files) {
$filename =~ m"^/" or return warn "$filename: please use absolute path\n";
-e $filename or die "$filename: no such file\n";
}
sync_cluster_pw() or die "$CLUSTER_PW_FILE: $!\n";
$donald_s=new My::Select::INET(Proto=>'udp') or die "$!\n";
for my $filename (@files) {
my $st=Donald::FileInfo->lstat($filename);
defined $st or die "$filename: $!\n";
$st->type eq 'F' or die "$filename: only plain files currently supported\n";
udp_broadcast_message($donald_s,'push',$my_ip,$st);
}
}

#------------------------------------------------------------

use constant USAGE => <<'__EOF__';
Expand All @@ -1690,6 +1706,8 @@ usage: $0 [options]
--foreground # stay in foreground, log to stderr
--syslog # log to syslog instead of stderr
push files.... # push files over tcp
__EOF__

use Getopt::Long;
Expand Down Expand Up @@ -1784,5 +1802,12 @@ if (defined $options{'push'}) {
} elsif ($options{'kill'}) {
Donald::Tools::kill_previous_server('clusterd');
} else {
die USAGE;
@ARGV or die USAGE;
my ($cmd,@args)=@ARGV;
if ($cmd eq 'push') {
@args>0 or die USAGE;
cmd_push(@args);
} else {
die USAGE;
}
}

0 comments on commit 305be8a

Please sign in to comment.