our $htmlout = ".";
our $read_existing=1;
our $doinstall=1;
+our $maxjobs=10;
our @blessings;
open DEBUG, ">/dev/null";
while (@ARGV && $ARGV[0] =~ m/^-/) {
$_= shift @ARGV;
last if m/^--?$/;
- if (m/^--(limit)\=([1-9]\d*)$/) {
+ if (m/^--(limit|maxjobs)\=([1-9]\d*)$/) {
$$1= $2;
} elsif (m/^--time-limit\=([1-9]\d*)$/) {
$timelimit= $1;
computeflightsrange();
});
+undef $dbh_tests;
+
+our %children;
+our $worst = 0;
+
+sub wait_for_max_children ($) {
+ my ($lim) = @_;
+ while (keys(%children) > $lim) {
+ $!=0; $?=0; my $got = wait;
+ die "$! $got $?" unless exists $children{$got};
+ my $host = $children{$got};
+ delete $children{$got};
+ $worst = $? if $? > $worst;
+ if ($?) {
+ print STDERR "sg-report-flight[: [$got] failed for $host: $?\n";
+ } else {
+ print DEBUG "REAPED [$got] $host\n";
+ }
+ }
+}
+
foreach my $host (sort keys %hosts) {
- read_existing_logs($host);
- db_retry($dbh_tests, [], sub {
- mainquery($host);
- reporthost $host;
- });
+ wait_for_max_children($maxjobs);
+
+ my $pid = fork // die $!;
+ if (!$pid) {
+ opendb_tests();
+ read_existing_logs($host);
+ db_retry($dbh_tests, [], sub {
+ mainquery($host);
+ reporthost $host;
+ });
+ print DEBUG "JQ CACHE ".($jqtotal-$jqcachemisses)." / $jqtotal\n";
+ exit(0);
+ }
+ print DEBUG "SPAWNED [$pid] $host\n";
+ $children{$pid} = $host;
}
-print DEBUG "JQ CACHE ".($jqtotal-$jqcachemisses)." / $jqtotal\n";
+wait_for_max_children(0);
+exit $worst;