Skip to content

Commit

Permalink
let's not run parallel-builder in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
DrHyde committed Mar 7, 2015
1 parent e9b53d0 commit 8d25885
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions parallel-builder.pl
Expand Up @@ -4,6 +4,9 @@
use warnings;
use Parallel::ForkManager;
use DBM::Deep;
use IPC::ConcurrencyLimit;

my $limit = concurrency_limit("/tmp/parallel-builder.lock");

my $build_script = shift(@ARGV);

Expand Down Expand Up @@ -51,3 +54,17 @@
file => "/tmp/parallel-builder-history.db",
);
$db_dbm->{$_} = $db->{$_} foreach (keys%{$db});

sub concurrency_limit {
my $lockfile = shift;
my $limit = IPC::ConcurrencyLimit->new(
max_procs => 1,
path => $lockfile,
);
my $limitid = $limit->get_lock;
if(not $limitid) {
warn "Another process appears to be still running. Exiting.";
exit(0);
}
return $limit;
}

0 comments on commit 8d25885

Please sign in to comment.