aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-07-08 18:26:05 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-07-08 18:26:05 +0100
commit240a321b053dfd244b696ab2b456e1c264c9456a (patch)
treec89bcae15c0c265573df89813143d47c59b81b30 /client.php
parentAdded basic Gearman worker/client (diff)
downloadgentoaster-240a321b053dfd244b696ab2b456e1c264c9456a.tar.gz
gentoaster-240a321b053dfd244b696ab2b456e1c264c9456a.tar.bz2
gentoaster-240a321b053dfd244b696ab2b456e1c264c9456a.zip
Added more robust error handling (we're not going to zombie onwards now when things fail)
Return codes and messages are now making it into a database, and job handles are mapped to handle hashes to prevent job hijacking
Diffstat (limited to 'client.php')
-rw-r--r--client.php28
1 files changed, 8 insertions, 20 deletions
diff --git a/client.php b/client.php
index 0110d3b..b289a34 100644
--- a/client.php
+++ b/client.php
@@ -8,26 +8,14 @@
echo "Sending job\n";
- do {
- $result = $client->do("invoke_image_build", file_get_contents("configs/minimal.ini"));
- switch($client->returnCode()) {
- case GEARMAN_WORK_DATA:
- break;
- case GEARMAN_WORK_STATUS:
- list($numerator, $denominator)= $client->doStatus();
- $progress = ceil($numerator/$denominator*100);
- echo "Status: $progress% complete\n";
- break;
- case GEARMAN_SUCCESS:
- echo "Job finished!\n";
- echo $result;
- break;
- default:
- echo "Return code: " . $client->returnCode() . "\n";
- exit;
- }
- }
+ $handle = $client->doBackground("invoke_image_build", file_get_contents("configs/crashtest.ini"));
+ $handlehash = md5($handle);
- while($client->returnCode() != GEARMAN_SUCCESS);
+ echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";
+ $db = mysql_connect("localhost","gentoaster","");
+ if(!$db) die("Could not connect to database ".mysql_error());
+ mysql_select_db("gentoaster");
+ mysql_query("INSERT INTO builds (id, handle) VALUES('".$handlehash."','".$handle."')");
+ echo "Job handle mapping added to database\n";
?>