forked from lix-project/hydra
* Monitor for dead builds all the time.
This commit is contained in:
parent
ba5e4be15e
commit
2156e406b4
|
@ -11,20 +11,22 @@ my $db = Hydra::Schema->connect("dbi:SQLite:dbname=hydra.sqlite", "", "", {});
|
||||||
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
$db->storage->dbh->do("PRAGMA synchronous = OFF;");
|
||||||
|
|
||||||
|
|
||||||
# Unlock jobs whose building process has died.
|
sub unlockDeadJobs {
|
||||||
$db->txn_do(sub {
|
# Unlock jobs whose building process has died.
|
||||||
my @jobs = $db->resultset('Builds')->search(
|
$db->txn_do(sub {
|
||||||
{finished => 0, busy => 1}, {join => 'schedulingInfo'});
|
my @jobs = $db->resultset('Builds')->search(
|
||||||
foreach my $job (@jobs) {
|
{finished => 0, busy => 1}, {join => 'schedulingInfo'});
|
||||||
my $pid = $job->schedulingInfo->locker;
|
foreach my $job (@jobs) {
|
||||||
if (kill(0, $pid) != 1) { # see if we can signal the process
|
my $pid = $job->schedulingInfo->locker;
|
||||||
print "job ", $job->id, " pid $pid died, unlocking\n";
|
if (kill(0, $pid) != 1) { # see if we can signal the process
|
||||||
$job->schedulingInfo->busy(0);
|
print "job ", $job->id, " pid $pid died, unlocking\n";
|
||||||
$job->schedulingInfo->locker("");
|
$job->schedulingInfo->busy(0);
|
||||||
$job->schedulingInfo->update;
|
$job->schedulingInfo->locker("");
|
||||||
|
$job->schedulingInfo->update;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
|
|
||||||
sub checkJobs {
|
sub checkJobs {
|
||||||
|
@ -112,6 +114,7 @@ sub checkJobs {
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
eval {
|
eval {
|
||||||
|
unlockDeadJobs;
|
||||||
checkJobs;
|
checkJobs;
|
||||||
};
|
};
|
||||||
warn $@ if $@;
|
warn $@ if $@;
|
||||||
|
|
Loading…
Reference in a new issue