summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEudyptula <eitan@mosenkis.net>2009-08-04 17:58:55 -0400
committerEudyptula <eitan@mosenkis.net>2009-08-04 17:58:55 -0400
commitd3da989d3e2d2cb03cdc4bd2e23783f716ef5035 (patch)
tree2f9f8c413d2800a3f72282dec0f86170a00ff4f6 /backend/backend.php
parentAdd visibility column to builds, configurations (diff)
downloadingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.tar.gz
ingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.tar.bz2
ingenue-d3da989d3e2d2cb03cdc4bd2e23783f716ef5035.zip
Widespread cleanup - moved $conf, $death into $S; $S is given as arg to init_x() and body_x(); $request removed in favor of $_REQUEST; query() replaces $S[pdo]->query(); etc.
Diffstat (limited to 'backend/backend.php')
-rwxr-xr-xbackend/backend.php24
1 files changed, 12 insertions, 12 deletions
diff --git a/backend/backend.php b/backend/backend.php
index 343be9f..5090c63 100755
--- a/backend/backend.php
+++ b/backend/backend.php
@@ -8,7 +8,7 @@ if (isset($opts['f'])) {
case -1:
die("Failed to fork");
case 0:
- $conf['debug']=false;
+ $S['conf']['debug']=false;
break;
default:
die();
@@ -49,19 +49,19 @@ declare(ticks=1);
require_once(SHARED.'/include/dbinit.php');
while (true) {
// TODO check first for builds that need to be resumed (and figure out how to resume things)
- $S['pdo']->query('LOCK TABLES `builds` WRITE');
- $r=$S['pdo']->query('SELECT * FROM `builds` WHERE `status`=-128 ORDER BY `ctime` ASC LIMIT 1');
+ query('LOCK TABLES `builds` WRITE');
+ $r=query('SELECT * FROM `builds` WHERE `status`=-128 ORDER BY `ctime` ASC LIMIT 1');
if ($r->rowCount()) {
$build=new sql_build($r->fetch(PDO::FETCH_ASSOC));
$build->start=time();
$build->status=-1;
$build->write();
- $S['pdo']->query('UNLOCK TABLES');
+ query('UNLOCK TABLES');
debug('Starting build id='.$build->id);
$file=null;
try {
- if ($conf['split_setup']) {
- $opt=new sql_buildopt($build->id, 'backend', $conf['backend_id']);
+ if ($S['conf']['split_setup']) {
+ $opt=new sql_buildopt($build->id, 'backend', $S['conf']['backend_id']);
$opt->write();
unset($opt);
}
@@ -75,7 +75,7 @@ while (true) {
require_once(BACKEND."/bundlers/{$opts['bundler']}.php");
$proc='bundle_'.$opts['bundler'];
$file=$proc($image, $workdir, $opts);
- if (!$conf['debug']) {
+ if (!$S['conf']['debug']) {
execute_command('Delete work directory', 'rm -rf "'.$workdir.'"');
}
} catch (Exception $e) {
@@ -83,13 +83,13 @@ while (true) {
log_msg('Caught exception: '.$e->getMessage());
$build->status=126;
$owner=$build->get_owner();
- xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $conf['title'].' build failed', 'Your build has failed. You can find more information at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
+ xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build failed', 'Your build has failed. You can find more information at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
}
$build->finish=time();
debug('Finished with build id='.$build->id);
if (isset($file)) {
debug("Completed build successfully");
- if ($conf['split_setup']) {
+ if ($S['conf']['split_setup']) {
$build->status=-127;
$build->write();
$key=randstring(30);
@@ -104,7 +104,7 @@ while (true) {
));
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$result=curl_exec($c);
- if ($conf['debug'] && is_string($result)) {
+ if ($S['conf']['debug'] && is_string($result)) {
debug($result);
}
if ($result === false || strpos($result, 'Upload successful') === false) {
@@ -120,12 +120,12 @@ while (true) {
$ext=substr($base, strpos($base, '.'));
rename($file, COMPLETED.'/build-'.$build->id.$ext);
}
- xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $conf['title'].' build finished', 'Your build has completed successfully. You can find more information and download the completed image at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
+ xhtmlemail('"'.$owner->name.'" <'.$owner->email.'>', null, $S['conf']['title'].' build finished', 'Your build has completed successfully. You can find more information and download the completed image at <a href="'.url("build/$build->id").'">'.url("build/$build->id").'</a>');
}
$build->write();
unset($build);
} else {
- $S['pdo']->query('UNLOCK TABLES');
+ query('UNLOCK TABLES');
}
// log_msg('Sleeping...', false);
sleep(5);