From: Christian Weiske Date: Thu, 10 Nov 2016 14:13:51 +0000 (+0100) Subject: add command to shut down a worker X-Git-Tag: v0.2.0~14 X-Git-Url: https://git.cweiske.de/phinde.git/commitdiff_plain/cbdbbfe1166538f2fc9aefaeed6ce387f25c1255?hp=31f0bc4f5a980b40ab8d6ebc6cf682e97f59f647 add command to shut down a worker --- 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 +addServer('127.0.0.1'); +$gmclient->doHigh( + $GLOBALS['phinde']['queuePrefix'] . 'phinde_quit', 'none' +); +?>