[Midnightbsd-cvs] mports: magus.pl: -j flag: run multiple instances in parallel.
ctriv at midnightbsd.org
ctriv at midnightbsd.org
Wed Sep 10 15:42:47 EDT 2008
Log Message:
-----------
-j flag: run multiple instances in parallel.
Modified Files:
--------------
mports/Tools/magus/slave:
magus.pl (r1.20 -> r1.21)
-------------- next part --------------
Index: magus.pl
===================================================================
RCS file: /home/cvs/mports/Tools/magus/slave/magus.pl,v
retrieving revision 1.20
retrieving revision 1.21
diff -L Tools/magus/slave/magus.pl -L Tools/magus/slave/magus.pl -u -r1.20 -r1.21
--- Tools/magus/slave/magus.pl
+++ Tools/magus/slave/magus.pl
@@ -49,6 +49,8 @@
my @origARGV = @ARGV;
my $self = '/usr/mports/Tools/magus/slave/magus.pl';
my $Lock;
+my $WorkerID = 1;
+
while (1) {
eval {
@@ -111,9 +113,26 @@
sub main {
my $lock;
- getopts('fv', \%opts);
+ getopts('fvj:', \%opts);
daemonize() unless $opts{f};
+
+ if ($opts{j}) {
+ while ($opts{j} > 1) {
+ my $pid = fork;
+
+ if ($pid) {
+ report(debug => "Forked child: $pid");
+ $opts{j}--;
+ next;
+ } elsif (defined $pid) {
+ $WorkerID++;
+ last;
+ } else {
+ die "Unable to fork child: $!\n";
+ }
+ }
+ }
report('info', "Starting magus on %s (%s)", $Magus::Machine->name, $Magus::Machine->arch);
@@ -152,7 +171,6 @@
END {
if ($Lock) {
- $Lock->port->reset;
$Lock->delete;
}
}
@@ -177,7 +195,10 @@
eval {
$port = $lock->port;
- $chroot = Magus::Chroot->new(tarball => $Magus::Config{ChrootTarBall});
+ $chroot = Magus::Chroot->new(
+ workerid => $WorkerID,
+ tarball => $Magus::Config{ChrootTarBall},
+ );
copy_dep_pkgfiles($lock, $chroot);
};
More information about the Midnightbsd-cvs
mailing list