note 126851 added to gearmanclient.addserver
| From: | iloveapplepie at main dot php dot net | Date: | Sat, 12 Feb 2022 18:52:21 +0000 |
| Subject: | note 126851 added to gearmanclient.addserver | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-217609@lists.php.net to get a copy of this message | ||
Sometimes you want the job server to start even if not all servers are available. The reason is
that if at a later point the server comes back gearman will use it, even if if failed during the add
server operation.
class SmartGearmanWorker extends GearmanWorker
{
function addServer($host = '127.0.0.1', $port = 4730):bool
{
try {
parent::addServer($host, $port);
echo "\nSERVER $host WORKED";
} catch (GearmanException $e) {
echo "\nSERVER $host FAILED";
}
return true;
}
}
class SmartGearmanClient extends GearmanClient
{
function addServer($host = '127.0.0.1', $port = 4730, bool $setupExceptionHandler =
false):bool
{
try {
parent::addServer($host, $port, $setupExceptionHandler);
echo "\nSERVER $host WORKED";
} catch (GearmanException $e) {
echo "\nSERVER $host FAILED"; //this does not get called even if the server is
down
}
return true;
}
}
----
Server IP: 45.112.84.4
Probable Submitter: 80.90.5.135 (proxied: 146.70.51.108)
----
Manual Page -- https://php.net/manual/en/gearmanclient.addserver.php
Edit -- https://main.php.net/note/edit/126851
Del: integrated -- https://main.php.net/note/delete/126851/integrated
Del: useless -- https://main.php.net/note/delete/126851/useless
Del: bad code -- https://main.php.net/note/delete/126851/bad+code
Del: spam -- https://main.php.net/note/delete/126851/spam
Del: non-english -- https://main.php.net/note/delete/126851/non-english
Del: in docs -- https://main.php.net/note/delete/126851/in+docs
Del: other reasons-- https://main.php.net/note/delete/126851
Reject -- https://main.php.net/note/reject/126851
Search -- https://main.php.net/manage/user-notes.php