From 17644ae3145edf84ebce8549bee98a8c1be3f6ea Mon Sep 17 00:00:00 2001 From: Eudyptula Date: Mon, 20 Jul 2009 16:39:03 -0400 Subject: Fixes/hacks so backend still works with non-execution logging --- backend/backend.php | 4 ++-- backend/functions/execution.php | 24 ++++++++++++++---------- frontend/css/build.css | 2 +- shared/classes/configuration.php | 2 +- shared/classes/task.php | 7 +++---- tidy | 8 ++++++++ todo | 3 ++- 7 files changed, 31 insertions(+), 19 deletions(-) create mode 100644 tidy diff --git a/backend/backend.php b/backend/backend.php index 6bf0bd7..9184694 100755 --- a/backend/backend.php +++ b/backend/backend.php @@ -86,9 +86,9 @@ while (true) { xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $conf['title'].' build failed', 'Your build has failed. You can find more information at '.url('logs/'.$build->id).''); } $build->finish=time(); - log_msg('Finished with build id='.$build->id); + debug('Finished with build id='.$build->id); if (isset($file)) { - log_msg("Completed build successfully"); + debug("Completed build successfully"); if ($conf['split_setup']) { $build->status=-127; $build->write(); diff --git a/backend/functions/execution.php b/backend/functions/execution.php index 773e6ee..0aee4d6 100644 --- a/backend/functions/execution.php +++ b/backend/functions/execution.php @@ -11,6 +11,18 @@ function task_get_order() { } return $order; } +function buildlog_entry_get_order() { + global $build, $task; + static $buildid, $taskorder, $order; + if ($buildid === $build->id && $taskorder === $task->order) { + $order++; + } else { + $buildid=$build->id; + $taskorder=$task->order; + $order=0; + } + return $order; +} function execute_command_with_all($description, $command, $fatal=true, $path=null, $env=null) { global $build, $task; if (isset($task)) @@ -64,26 +76,18 @@ function end_internal_task($status=0) { } function log_msg($msg, $nl=true) { global $build, $task; - static $order, $buildid, $taskorder; if (!isset($task)) { start_internal_task($msg); return; } $msg.=$nl?"\n":''; debug($msg); - if ($buildid === $build->id && $taskorder === $task->order) { - $order++; - } else { - $buildid=$build->id; - $taskorder=$task->order; - $order=0; - } - $entry=new sql_buildlog_entry($build->id, $task->order, $order, time(), 'system', $msg); + $entry=new sql_buildlog_entry($build->id, $task->order, buildlog_entry_get_order(), time(), 'system', $msg); $entry->write(); } function log_status($msg, $cmd) { start_internal_task($msg); - $status=is_bool($cmd)?$cmd:eval((strpos($cmd, 'return') === false?'return ':'').$cmd); + $status=is_string($cmd)?eval((strpos($cmd, 'return') === false?'return ':'').$cmd):$cmd; end_internal_task($status?0:1); debug("... ".($status?color('[success]', 'green'):color('[failure]', 'red'))); return $status; diff --git a/frontend/css/build.css b/frontend/css/build.css index 43ade38..344ae1c 100644 --- a/frontend/css/build.css +++ b/frontend/css/build.css @@ -38,7 +38,7 @@ div.build span.downloads span.time { div.build span.links { font-size: 90%; } -div.build span.links a:visited { +div.build span.links a:visited, div.build span.downloads a:visited { color: blue; } div.build div.time { diff --git a/shared/classes/configuration.php b/shared/classes/configuration.php index e315047..a3cdec3 100644 --- a/shared/classes/configuration.php +++ b/shared/classes/configuration.php @@ -53,7 +53,7 @@ class sql_configuration extends conf_build_common { $opt->write(); } $build->ctime=time(); - $build->status=1; + $build->status=-128; $build->write(); return $build; } diff --git a/shared/classes/task.php b/shared/classes/task.php index d5578b2..571c895 100644 --- a/shared/classes/task.php +++ b/shared/classes/task.php @@ -81,7 +81,7 @@ class sql_task extends sql_row_obj { throw_exception('task has already executed: start is '.$this->start); } $this->type='exec'; - log_msg('Executing '.$this->command.'...', false); + debug('Executing '.$this->command.'...'); $descriptorspec=array( 0 => array('pipe', 'r'), // STDIN 1 => array('pipe', 'w'), // STDOUT @@ -98,7 +98,6 @@ class sql_task extends sql_row_obj { foreach ($pipes as $pipe) { stream_set_blocking($pipe, 0); } - $msg=0; while (true) { $null=null; // We have to set these all to variables because stream_select requires pass by reference $outs=array_slice($pipes, 1); @@ -108,13 +107,13 @@ class sql_task extends sql_row_obj { $c=stream_get_contents($pipes[2]); if ($c) { // STDERR - $entry=new sql_buildlog_entry($this->build, $this->order, $msg++, time(), 'stderr', $c); + $entry=new sql_buildlog_entry($this->build, $this->order, buildlog_entry_get_order(), time(), 'stderr', $c); $entry->write(); } $c=stream_get_contents($pipes[1]); if ($c) { // STDOUT - $entry=new sql_buildlog_entry($this->build, $this->order, $msg++, time(), 'stdout', $c); + $entry=new sql_buildlog_entry($this->build, $this->order, buildlog_entry_get_order(), time(), 'stdout', $c); $entry->write(); } } diff --git a/tidy b/tidy new file mode 100644 index 0000000..ffb464c --- /dev/null +++ b/tidy @@ -0,0 +1,8 @@ +builds + buildopts + buildlogs + downloads + work dirs + completed +registrationtokens (expire < time()) +sessions (expire < time()) diff --git a/todo b/todo index 0f28295..f9e1c2f 100644 --- a/todo +++ b/todo @@ -1,5 +1,5 @@ Write a live git ebuild -*** Add logging besides just commands *** +Fix up backend logging so everything isn't its own task Have builds and tasks not give links to logs if we're already viewing the logs Consider logging env. passed to tasks, path if we ever use it Add a statistics page @@ -15,3 +15,4 @@ Allow config viewing for builds, not just configurations Write basic command-line wrapper to bkisofs and replace the ISO mounter with it Fix emerge system cache to discard properly Add `flags` column to configurations, builds, use it to implement public and private things +Clean up backend API -- cgit v1.2.3-65-gdbad