获取错误PHP警告:在运行客户端脚本期间,在gearman_client_run_tasks()期间发生了GearmanClient :: do():_ client_do(GEARMAN_TIMEOUT)。
//------------worker.php
#!/usr/bin/php -q
<?php
$worker = new GearmanWorker();
$worker->addServer();
$worker->addFunction( "test" , "test_function" );
while ($worker->work());
function test_function( $job )
{
return strtoupper($job->workload());
}
?>
//------------client.php
<?php
$client = new GearmanClient();
$client->addServer();
$client->setTimeout(1000);
print "\n";
print $client->do( "test" , "this is a test" );
die();
?>
答案 0 :(得分:0)
使用nohub posix命令在后台运行worker
nohup / usr / bin / php worker.php&gt; / dev / null 2&gt;&amp; 1&amp;
php client.php