aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2016-11-10 15:13:51 +0100
committerChristian Weiske <cweiske@cweiske.de>2016-11-10 15:13:51 +0100
commitcbdbbfe1166538f2fc9aefaeed6ce387f25c1255 (patch)
tree44dd4f2152572cb0d2747d653d175b6a9e343f9c
parent31f0bc4f5a980b40ab8d6ebc6cf682e97f59f647 (diff)
downloadphinde-cbdbbfe1166538f2fc9aefaeed6ce387f25c1255.tar.gz
phinde-cbdbbfe1166538f2fc9aefaeed6ce387f25c1255.zip
add command to shut down a worker
-rwxr-xr-xbin/phinde-worker.php9
-rwxr-xr-xbin/stop-worker.php12
2 files changed, 21 insertions, 0 deletions
diff --git a/bin/phinde-worker.php b/bin/phinde-worker.php
index 1e94535..9f8c35a 100755
--- a/bin/phinde-worker.php
+++ b/bin/phinde-worker.php
@@ -23,6 +23,15 @@ $gmworker->addFunction(
}
);
+$gmworker->addFunction(
+ $GLOBALS['phinde']['queuePrefix'] . 'phinde_quit',
+ function(\GearmanJob $job) {
+ echo "Got exit job\n";
+ $job->sendComplete('');
+ exit(0);
+ }
+);
+
while ($gmworker->work()) {
if ($gmworker->returnCode() != GEARMAN_SUCCESS) {
echo 'Error running job: ' . $gmworker->returnCode() . "\n";
diff --git a/bin/stop-worker.php b/bin/stop-worker.php
new file mode 100755
index 0000000..48a2fe1
--- /dev/null
+++ b/bin/stop-worker.php
@@ -0,0 +1,12 @@
+#!/usr/bin/env php
+<?php
+//stop a single running worker
+namespace phinde;
+require_once __DIR__ . '/../src/init.php';
+
+$gmclient = new \GearmanClient();
+$gmclient->addServer('127.0.0.1');
+$gmclient->doHigh(
+ $GLOBALS['phinde']['queuePrefix'] . 'phinde_quit', 'none'
+);
+?>