This commit is contained in:
Eelco Dolstra 2008-11-27 18:54:25 +00:00
parent d6f71f2248
commit ac89e7d4ed

View file

@ -27,11 +27,16 @@ $db->txn_do(sub {
}); });
sub logfileForBuild {
my ($id) = @_;
return getcwd . "/logs/" . $id;
}
sub checkJobs { sub checkJobs {
print "looking for runnable jobs...\n"; print "looking for runnable jobs...\n";
my @jobsStarted; my @jobsStarted;
my $logfile;
$db->txn_do(sub { $db->txn_do(sub {
@ -67,8 +72,7 @@ sub checkJobs {
"starting ", scalar(@jobs), " builds\n"; "starting ", scalar(@jobs), " builds\n";
foreach my $job (@jobs) { foreach my $job (@jobs) {
$logfile = getcwd . "/logs/" . $job->id; unlink(logfileForBuild $job->id);
unlink $logfile;
$job->schedulingInfo->busy(1); $job->schedulingInfo->busy(1);
$job->schedulingInfo->locker($$); $job->schedulingInfo->locker($$);
$job->schedulingInfo->logfile($logfile); $job->schedulingInfo->logfile($logfile);
@ -89,6 +93,7 @@ sub checkJobs {
my $child = fork(); my $child = fork();
die unless defined $child; die unless defined $child;
if ($child == 0) { if ($child == 0) {
my $logfile = logfileForBuild $job->id;
open LOG, ">$logfile" or die; open LOG, ">$logfile" or die;
POSIX::dup2(fileno(LOG), 1) or die; POSIX::dup2(fileno(LOG), 1) or die;
POSIX::dup2(fileno(LOG), 2) or die; POSIX::dup2(fileno(LOG), 2) or die;