From 632bb24687e18ab6dd6a8e7c95214d42382a20cf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Nov 2008 14:45:33 +0000 Subject: [PATCH] --- .../lib/HydraFrontend/Controller/Root.pm | 5 ++ src/HydraFrontend/root/build.tt | 60 +++++++++++++++---- src/HydraFrontend/root/index.tt | 15 ++++- src/build.pl | 10 +--- src/runner.pl | 7 ++- 5 files changed, 77 insertions(+), 20 deletions(-) diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 5c9e8f91..f5100ea5 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -80,6 +80,11 @@ sub build :Local { $c->stash->{template} = 'build.tt'; $c->stash->{build} = $build; $c->stash->{id} = $id; + + if (!$build->finished && $build->schedulingInfo->busy) { + my $logfile = $build->schedulingInfo->logfile; + $c->stash->{logtext} = `cat $logfile`; + } } diff --git a/src/HydraFrontend/root/build.tt b/src/HydraFrontend/root/build.tt index 67f29b2b..b824a0c9 100644 --- a/src/HydraFrontend/root/build.tt +++ b/src/HydraFrontend/root/build.tt @@ -4,7 +4,11 @@

Job [% build.project.name %]:[% build.attrname %] build [% id %] [% IF !build.finished %] - (scheduled) + [% IF build.schedulingInfo.busy %] + (currently building) + [% ELSE %] + (scheduled) + [% END %] [% END %]

@@ -20,6 +24,27 @@ Time added: [% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %] + + Status: + + [% IF build.finished %] + [% IF build.resultInfo.buildstatus == 0 %] + + Success + [% ELSIF build.resultInfo.buildstatus == 1 %] + + Build returned a non-zero exit code + [% ELSE %] + + Build failed + [% END %] + [% ELSIF build.schedulingInfo.busy %] + Build in progress + [% ELSE %] + Scheduled to be built + [% END %] + + Project: [% build.project.name %] @@ -67,21 +92,17 @@ [% END %] - - Status: - - [% IF build.resultInfo.buildstatus == 0 %] - - [% ELSE %] - - [% END %] - - [% ELSE %] Priority: [% build.schedulingInfo.priority %] + [% IF build.schedulingInfo.busy %] + + Logfile: + [% build.schedulingInfo.logfile %] + + [% END %] [% END %] @@ -115,6 +136,10 @@ [% IF build.finished %] + +[% IF build.buildproducts %] + +

Build products

+[% END %] +

Logs

@@ -179,6 +206,17 @@ [% END %] +[% ELSIF build.schedulingInfo.busy %] + + +

Log

+ + +
+[% logtext -%]
+
+ + [% END %] diff --git a/src/HydraFrontend/root/index.tt b/src/HydraFrontend/root/index.tt index d1c61cab..fb8f3200 100644 --- a/src/HydraFrontend/root/index.tt +++ b/src/HydraFrontend/root/index.tt @@ -1,8 +1,15 @@ [% WRAPPER layout.tt title="Hydra Overview" %] [% USE date %] +

Queue

+[% IF scheduled.size == 0 %] + +

The queue is empty.

+ +[% ELSE %] + @@ -13,7 +20,7 @@ - + @@ -22,6 +29,9 @@
#PriorityProjectJobSystemTimestampDescription
[% build.id %] [% build.schedulingInfo.priority %] [% build.project.name %][% build.jobset.name %][% build.attrname %] [% build.system %] [% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %] [% build.description %]
+[% END %] + +

Job status

Below are the latest builds for each job.

@@ -37,6 +47,7 @@ +

All builds

Number of builds: [% allBuilds.size %]

@@ -52,6 +63,7 @@ +

Projects

+ [% END %] diff --git a/src/build.pl b/src/build.pl index b35e7aa5..1a4dfae8 100644 --- a/src/build.pl +++ b/src/build.pl @@ -32,8 +32,6 @@ sub doBuild { $startTime = time(); - print " BUILDING\n"; - my $res = system("nix-store --realise $drvPath"); $stopTime = time(); @@ -66,7 +64,7 @@ sub doBuild { my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath; if (-e $logPath) { - print " LOG $logPath\n"; + print "found log $logPath\n"; $db->resultset('Buildlogs')->create( { build => $build->id , logphase => "full" @@ -79,7 +77,7 @@ sub doBuild { if (-e "$outPath/log") { foreach my $logPath (glob "$outPath/log/*") { - print " LOG $logPath\n"; + print "found log $logPath\n"; $db->resultset('Buildlogs')->create( { build => $build->id , logphase => basename($logPath) @@ -105,7 +103,7 @@ sub doBuild { }); } close LIST; - } else { + } elsif ($buildStatus == 0) { $db->resultset('Buildproducts')->create( { build => $build->id , type => "nix-build" @@ -144,9 +142,7 @@ die unless $build; # Do the build. If it throws an error, unlock the build so that it # can be retried. eval { - print "BUILD\n"; doBuild $build; - print "DONE\n"; }; if ($@) { warn $@; diff --git a/src/runner.pl b/src/runner.pl index 8d45721a..394ed1d0 100644 --- a/src/runner.pl +++ b/src/runner.pl @@ -1,6 +1,7 @@ #! @perl@ -w use strict; +use Cwd; use POSIX qw(dup2); use HydraFrontend::Schema; @@ -31,6 +32,7 @@ sub checkJobs { print "looking for runnable jobs...\n"; my $job; + my $logfile; $db->txn_do(sub { @@ -42,8 +44,11 @@ sub checkJobs { if (scalar @jobs > 0) { $job = $jobs[0]; + $logfile = getcwd . "/logs/" . $job->id; + unlink $logfile; $job->schedulingInfo->busy(1); $job->schedulingInfo->locker($$); + $job->schedulingInfo->logfile($logfile); $job->schedulingInfo->update; } @@ -58,7 +63,7 @@ sub checkJobs { my $child = fork(); die unless defined $child; if ($child == 0) { - open LOG, ">logs/$id" or die; + open LOG, ">$logfile" or die; POSIX::dup2(fileno(LOG), 1) or die; POSIX::dup2(fileno(LOG), 2) or die; exec("perl", "-IHydraFrontend/lib", "-w",