Reputation: 1709
I am trying to execute this minimal example of a gearman Job Server with php:
worker.php:
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$worker= new GearmanWorker();
$worker->addServer();
$worker->addFunction("reverse", "my_reverse_function");
echo "Starting Worker...\n";
while ($worker->work());
function my_reverse_function($job)
{
return strrev($job->workload());
}
?>
client.php:
<?php
ini_set('display_errors', 1);
error_reporting(~0);
echo "Starting Client...\n";
$client= new GearmanClient();
$client->addServer();
print $client->doNormal("reverse", "Hello World!");
?>
I am trying it in the console with php worker.php
which gives the output "Starting Worker..."
Then I am trying php client.php
(in another console-window) which gives the output Starting Client... (no more). However I am expecting the output "!dlroW olleH" or at least a suitable error message....
The code following gives me the output: 1.0.6, so I am assuming, the gearman software is installed correctly. I am on a debian 8.1 btw.
<?php
echo gearman_version();
?>
What is wrong? Why does my Gearman Worker and / or Client not work?
Upvotes: 0
Views: 1037
Reputation: 1709
Adding the IP (instead of the default value "localhost"), solved the issue.
$worker->addServer("127.0.0.1");
Upvotes: 3