projects
/
clearscm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
More changes to standardize Songbook
[clearscm.git]
/
bin
/
rexec
diff --git
a/bin/rexec
b/bin/rexec
index
3dad3ac
..
48dea14
100755
(executable)
--- a/
bin/rexec
+++ b/
bin/rexec
@@
-80,7
+80,7
@@
sub Interrupted {
display BLUE . "\nInterrupted execution on $currentHost" . RESET;
display BLUE . "\nInterrupted execution on $currentHost" . RESET;
- Stats \%total
, $log
;
+ Stats \%total;
display_nolf "Executing on " . YELLOW . $currentHost . RESET . " - "
. GREEN . BOLD . "S" . RESET . GREEN . "kip" . RESET . ", "
display_nolf "Executing on " . YELLOW . $currentHost . RESET . " - "
. GREEN . BOLD . "S" . RESET . GREEN . "kip" . RESET . ", "
@@
-109,7
+109,7
@@
sub Interrupted {
$total{Skips}++;
} elsif ($answer eq "a") {
display RED . "Aborting run". RESET;
$total{Skips}++;
} elsif ($answer eq "a") {
display RED . "Aborting run". RESET;
- Stats \%total
, $log
;
+ Stats \%total;
exit;
} else {
display "Continuing...";
exit;
} else {
display "Continuing...";
@@
-193,34
+193,37
@@
sub execute ($$;$) {
return ($status, @lines);
} # execute
return ($status, @lines);
} # execute
-sub parallelize ($
%
) {
- my ($cmd,
%
machines) = @_;
+sub parallelize ($
@
) {
+ my ($cmd,
@
machines) = @_;
my $thread_count = 1;
my $thread_count = 1;
- foreach my $host (sort keys %machines) {
+ foreach (@machines) {
+ my %system = %$_;
+
if ($thread_count <= $opts{parallel}) {
if ($thread_count <= $opts{parallel}) {
- debug "Processing $
host
($thread_count)";
+ debug "Processing $
system{name}
($thread_count)";
$thread_count++;
if (my $pid = fork) {
# In parent process - record this host and its status
$thread_count++;
if (my $pid = fork) {
# In parent process - record this host and its status
- $workerNames{$pid} = $host;
+ display "Putting $system{name} into workerName{$pid}";
+ $workerNames{$pid} = $system{host};
} else {
# In spawned child...
$pid = $$;
} else {
# In spawned child...
$pid = $$;
- debug "Starting process for $
host
[$pid]";
+ debug "Starting process for $
system{name}
[$pid]";
- $workerNames{$pid} = $
host
;
+ $workerNames{$pid} = $
system{name}
;
# Mark currentHost for interrupt (How does this work in the presence
# of parallelization?).
# Mark currentHost for interrupt (How does this work in the presence
# of parallelization?).
- $currentHost = $
host
;
+ $currentHost = $
system{name}
;
- my ($status, @lines) = execute $cmd, $
host, $machines{$host
};
+ my ($status, @lines) = execute $cmd, $
system{name
};
- $log = Logger->new (name => $
host
);
+ $log = Logger->new (name => $
system{name}
);
$log->log ($_) foreach (@lines);
$log->log ($_) foreach (@lines);
@@
-229,8
+232,16
@@
sub parallelize ($%) {
} else {
# Wait for somebody to finish;
debug "Waiting for somebody to exit...";
} else {
# Wait for somebody to finish;
debug "Waiting for somebody to exit...";
+
+ display "Current status of workerNames:";
+ display $_ foreach (keys %workerNames);
my $reaped = wait;
my $reaped = wait;
+ if ($workerNames{$reaped}) {
+ display "workerNames for pid $reaped exists!";
+ } else {
+ display "workerNames for pid $reaped does not exist!";
+ }
debug "Reaped $workerNames{$reaped} [$reaped] (Status: $?)";
$workerStatuses{$reaped} = $? >> 8 if $reaped != -1;
debug "Reaped $workerNames{$reaped} [$reaped] (Status: $?)";
$workerStatuses{$reaped} = $? >> 8 if $reaped != -1;
@@
-260,13
+271,15
@@
sub parallelize ($%) {
# Gather output...
display "Output of all executions";
# Gather output...
display "Output of all executions";
- foreach my $host (sort keys %machines) {
- if (-f "$host.log") {
- display "$host:$_" foreach (ReadFile ("$host.log"));
+ foreach (@machines) {
+ my %system = %$_;
+
+ if (-f "$system{name}.log") {
+ display "$system{name}:$_" foreach (ReadFile ("$system{name}.log"));
-
#unlink "$_host
.log";
+
unlink "$system{name}
.log";
} else {
} else {
- warning "Unable to find output for $
host ($host
.log missing)";
+ warning "Unable to find output for $
system{name} ($system{name}
.log missing)";
} # if
} # foreach
} # if
} # foreach
@@
-296,7
+309,9
@@
pod2usage ('No command specified') unless $cmd;
my $machines = Clearadm->new;
if ($opts{parallel} > 0) {
my $machines = Clearadm->new;
if ($opts{parallel} > 0) {
- #parallelize ($cmd, %machines);
+ my @machines = $machines->SearchSystem ("type='$opts{type}'");
+
+ parallelize ($cmd, @machines);
Stats \%total, $log;
exit;
} # if
Stats \%total, $log;
exit;
} # if