aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-07-08 03:44:09 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-07-08 03:44:09 +0100
commit9d971158f5fb4888f8ac33540c85801a6064bcda (patch)
tree6d3832c0160cb4bee165de0c3918c19176072883 /client.php
parentFix minimal config and incorrect cachedkernel logic (diff)
downloadgentoaster-9d971158f5fb4888f8ac33540c85801a6064bcda.tar.gz
gentoaster-9d971158f5fb4888f8ac33540c85801a6064bcda.tar.bz2
gentoaster-9d971158f5fb4888f8ac33540c85801a6064bcda.zip
Added basic Gearman worker/client
Client is only for testing purposes, real client will be part of WebUI Worker needs better error handling, does work in current form though Added progress reporting hack in create_image.sh, going to replace this with a better system soon
Diffstat (limited to 'client.php')
-rw-r--r--client.php33
1 files changed, 33 insertions, 0 deletions
diff --git a/client.php b/client.php
new file mode 100644
index 0000000..0110d3b
--- /dev/null
+++ b/client.php
@@ -0,0 +1,33 @@
+<?php
+
+ // Gentoaster build daemon client
+ // Licensed under GPL v3, see COPYING file
+
+ $client= new GearmanClient();
+ $client->addServer();
+
+ 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;
+ }
+ }
+
+ while($client->returnCode() != GEARMAN_SUCCESS);
+
+?>