hydra-queue-runner: Set the start time properly

This commit is contained in:
Eelco Dolstra 2013-09-21 19:38:02 +00:00
parent 52ce662710
commit 4cdf1a270d

View file

@ -28,7 +28,7 @@ sub unlockDeadBuilds {
my $pid = $build->locker;
my $unlock = 0;
if ($pid == $$) {
if (!defined $lastTime || $build->starttime < $lastTime - 180) {
if (!defined $lastTime || $build->starttime < $lastTime - 300) {
$unlock = 1;
}
} elsif (kill(0, $pid) != 1) { # see if we can signal the process
@ -36,7 +36,7 @@ sub unlockDeadBuilds {
}
if ($unlock) {
print "build ", $build->id, " pid $pid died, unlocking\n";
$build->update({ busy => 0, locker => ""});
$build->update({ busy => 0, locker => "" });
$build->buildsteps->search({ busy => 1 })->update({ busy => 0, status => 4, stoptime => time });
}
}
@ -174,7 +174,6 @@ sub checkBuilds {
{ busy => 1
, locker => $$
, logfile => $logfile
, starttime => time()
});
push @buildsStarted, $build;
next j;
@ -184,6 +183,10 @@ sub checkBuilds {
last; # nothing found, give up on this system type
}
}
$lastTime = time();
$_->update({ starttime => time() }) foreach @buildsStarted;
});
# Actually start the builds we just selected. We need to do this
@ -208,9 +211,7 @@ sub checkBuilds {
if ($@) {
warn $@;
txn_do($db, sub {
$build->busy(0);
$build->locker($$);
$build->update;
$build->update({ busy => 0, locker => $$ });
});
}
}
@ -230,8 +231,6 @@ while (1) {
unlockDeadBuilds;
$lastTime = time();
checkBuilds;
};
warn $@ if $@;