This commit is contained in:
Eelco Dolstra 2008-11-11 14:45:33 +00:00
parent ecd0ba74e9
commit 632bb24687
5 changed files with 77 additions and 20 deletions

View file

@ -80,6 +80,11 @@ sub build :Local {
$c->stash->{template} = 'build.tt'; $c->stash->{template} = 'build.tt';
$c->stash->{build} = $build; $c->stash->{build} = $build;
$c->stash->{id} = $id; $c->stash->{id} = $id;
if (!$build->finished && $build->schedulingInfo->busy) {
my $logfile = $build->schedulingInfo->logfile;
$c->stash->{logtext} = `cat $logfile`;
}
} }

View file

@ -4,7 +4,11 @@
<h1> <h1>
Job <tt>[% build.project.name %]:[% build.attrname %]</tt> build [% id %] Job <tt>[% build.project.name %]:[% build.attrname %]</tt> build [% id %]
[% IF !build.finished %] [% IF !build.finished %]
(scheduled) [% IF build.schedulingInfo.busy %]
(currently building)
[% ELSE %]
(scheduled)
[% END %]
[% END %] [% END %]
</h1> </h1>
@ -20,6 +24,27 @@
<th>Time added:</th> <th>Time added:</th>
<td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td> <td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td>
</tr> </tr>
<tr>
<th>Status:</th>
<td>
[% IF build.finished %]
[% IF build.resultInfo.buildstatus == 0 %]
<img src="/static/images/success.gif" />
<strong>Success</strong>
[% ELSIF build.resultInfo.buildstatus == 1 %]
<img src="/static/images/failure.gif" />
<strong>Build returned a non-zero exit code</strong>
[% ELSE %]
<img src="/static/images/failure.gif" />
<strong>Build failed</strong>
[% END %]
[% ELSIF build.schedulingInfo.busy %]
<strong>Build in progress</strong>
[% ELSE %]
<strong>Scheduled to be built</strong>
[% END %]
</td>
</tr>
<tr> <tr>
<th>Project:</th> <th>Project:</th>
<td><a href="[% c.uri_for('/project' build.project.name) %]"><tt>[% build.project.name %]</tt></a></td> <td><a href="[% c.uri_for('/project' build.project.name) %]"><tt>[% build.project.name %]</tt></a></td>
@ -67,21 +92,17 @@
[% END %] [% END %]
</td> </td>
</tr> </tr>
<tr>
<th>Status:</th>
<td>
[% IF build.resultInfo.buildstatus == 0 %]
<img src="/static/images/success.gif" />
[% ELSE %]
<img src="/static/images/failure.gif" />
[% END %]
</td>
</tr>
[% ELSE %] [% ELSE %]
<tr> <tr>
<th>Priority:</th> <th>Priority:</th>
<td>[% build.schedulingInfo.priority %]</td> <td>[% build.schedulingInfo.priority %]</td>
</tr> </tr>
[% IF build.schedulingInfo.busy %]
<tr>
<th>Logfile:</th>
<td>[% build.schedulingInfo.logfile %]</td>
</tr>
[% END %]
[% END %] [% END %]
</table> </table>
@ -115,6 +136,10 @@
[% IF build.finished %] [% IF build.finished %]
[% IF build.buildproducts %]
<h2>Build products</h2> <h2>Build products</h2>
<ul class="productList"> <ul class="productList">
@ -141,6 +166,8 @@
</ul> </ul>
[% END %]
<h2>Logs</h2> <h2>Logs</h2>
@ -179,6 +206,17 @@
[% END %] [% END %]
[% ELSIF build.schedulingInfo.busy %]
<h2>Log</h2>
<!-- !!! escaping -->
<pre class="buildlog">
[% logtext -%]
</pre>
[% END %] [% END %]

View file

@ -1,8 +1,15 @@
[% WRAPPER layout.tt title="Hydra Overview" %] [% WRAPPER layout.tt title="Hydra Overview" %]
[% USE date %] [% USE date %]
<h1>Queue</h1> <h1>Queue</h1>
[% IF scheduled.size == 0 %]
<p>The queue is empty.</p>
[% ELSE %]
<table class="tablesorter"> <table class="tablesorter">
<thead> <thead>
<tr><th>#</th><th>Priority</th><th>Project</th><th>Job</th><th>System</th><th>Timestamp</th><th>Description</th></tr> <tr><th>#</th><th>Priority</th><th>Project</th><th>Job</th><th>System</th><th>Timestamp</th><th>Description</th></tr>
@ -13,7 +20,7 @@
<td><a href="[% c.uri_for('/build' build.id) %]">[% build.id %]</a></td> <td><a href="[% c.uri_for('/build' build.id) %]">[% build.id %]</a></td>
<td>[% build.schedulingInfo.priority %]</td> <td>[% build.schedulingInfo.priority %]</td>
<td><tt>[% build.project.name %]</tt></td> <td><tt>[% build.project.name %]</tt></td>
<td><tt>[% build.jobset.name %]</tt></td> <td><tt>[% build.attrname %]</tt></td>
<td><tt>[% build.system %]</tt></td> <td><tt>[% build.system %]</tt></td>
<td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td> <td>[% date.format(build.timestamp, '%Y-%m-%d %H:%M:%S') %]</td>
<td>[% build.description %]</td> <td>[% build.description %]</td>
@ -22,6 +29,9 @@
</tbody> </tbody>
</table> </table>
[% END %]
<h1>Job status</h1> <h1>Job status</h1>
<p>Below are the latest builds for each job.</p> <p>Below are the latest builds for each job.</p>
@ -37,6 +47,7 @@
</tbody> </tbody>
</table> </table>
<h1>All builds</h1> <h1>All builds</h1>
<p>Number of builds: [% allBuilds.size %]</p> <p>Number of builds: [% allBuilds.size %]</p>
@ -52,6 +63,7 @@
</tbody> </tbody>
</table> </table>
<h1>Projects</h1> <h1>Projects</h1>
<ul> <ul>
@ -60,4 +72,5 @@
[% END -%] [% END -%]
</ul> </ul>
[% END %] [% END %]

View file

@ -32,8 +32,6 @@ sub doBuild {
$startTime = time(); $startTime = time();
print " BUILDING\n";
my $res = system("nix-store --realise $drvPath"); my $res = system("nix-store --realise $drvPath");
$stopTime = time(); $stopTime = time();
@ -66,7 +64,7 @@ sub doBuild {
my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath; my $logPath = "/nix/var/log/nix/drvs/" . basename $drvPath;
if (-e $logPath) { if (-e $logPath) {
print " LOG $logPath\n"; print "found log $logPath\n";
$db->resultset('Buildlogs')->create( $db->resultset('Buildlogs')->create(
{ build => $build->id { build => $build->id
, logphase => "full" , logphase => "full"
@ -79,7 +77,7 @@ sub doBuild {
if (-e "$outPath/log") { if (-e "$outPath/log") {
foreach my $logPath (glob "$outPath/log/*") { foreach my $logPath (glob "$outPath/log/*") {
print " LOG $logPath\n"; print "found log $logPath\n";
$db->resultset('Buildlogs')->create( $db->resultset('Buildlogs')->create(
{ build => $build->id { build => $build->id
, logphase => basename($logPath) , logphase => basename($logPath)
@ -105,7 +103,7 @@ sub doBuild {
}); });
} }
close LIST; close LIST;
} else { } elsif ($buildStatus == 0) {
$db->resultset('Buildproducts')->create( $db->resultset('Buildproducts')->create(
{ build => $build->id { build => $build->id
, type => "nix-build" , type => "nix-build"
@ -144,9 +142,7 @@ die unless $build;
# Do the build. If it throws an error, unlock the build so that it # Do the build. If it throws an error, unlock the build so that it
# can be retried. # can be retried.
eval { eval {
print "BUILD\n";
doBuild $build; doBuild $build;
print "DONE\n";
}; };
if ($@) { if ($@) {
warn $@; warn $@;

View file

@ -1,6 +1,7 @@
#! @perl@ -w #! @perl@ -w
use strict; use strict;
use Cwd;
use POSIX qw(dup2); use POSIX qw(dup2);
use HydraFrontend::Schema; use HydraFrontend::Schema;
@ -31,6 +32,7 @@ sub checkJobs {
print "looking for runnable jobs...\n"; print "looking for runnable jobs...\n";
my $job; my $job;
my $logfile;
$db->txn_do(sub { $db->txn_do(sub {
@ -42,8 +44,11 @@ sub checkJobs {
if (scalar @jobs > 0) { if (scalar @jobs > 0) {
$job = $jobs[0]; $job = $jobs[0];
$logfile = getcwd . "/logs/" . $job->id;
unlink $logfile;
$job->schedulingInfo->busy(1); $job->schedulingInfo->busy(1);
$job->schedulingInfo->locker($$); $job->schedulingInfo->locker($$);
$job->schedulingInfo->logfile($logfile);
$job->schedulingInfo->update; $job->schedulingInfo->update;
} }
@ -58,7 +63,7 @@ sub checkJobs {
my $child = fork(); my $child = fork();
die unless defined $child; die unless defined $child;
if ($child == 0) { 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), 1) or die;
POSIX::dup2(fileno(LOG), 2) or die; POSIX::dup2(fileno(LOG), 2) or die;
exec("perl", "-IHydraFrontend/lib", "-w", exec("perl", "-IHydraFrontend/lib", "-w",