1

所以,我现在运行了一个简单的齿轮系统,一个工人在运行。

工作人员基本上只是获取有效负载(在这种情况下是一个随机数,并且应该将其回显到屏幕上。字面意思是一个echo,而不是返回给客户端。

客户端发送随机数。我试图做一个,但它每次都会$client->doBackground( 'post', 65482, md5(uniqid()));返回一个 47 错误( )。GEARMAN_TIMEOUT

getErrNo()返回 0,error()返回关于GEARMAN_TIMEOUT

但是,当我将其更改为 just 时$client->do(blah, blah, blah),它工作得很好。

我什至偶尔会看到工作人员仍然回显数字,即使在收到超时错误之后...

public function execute()
    {
        $method = 'do';
        if( !$this->getBlock() )
        {
            $method .= ( $this->getPriority() == 'Normal' ? '' : $this->getPriority() ) . 'Background';
        }
        else
        {
            $method .= $this->getPriority();
        }
        echo "Method: $method \t Worker: {$this->getName()} \t Payload: {$this->getPayload()} \t Hash: {$this->getHash()}\n";
        $this->setResult(
            $this->getClient()
                ->$method(
                    $this->getName(),
                    $this->getPayload(),
                    $this->getHash()
                )
        );
        if( $this->getClient()->returnCode() != GEARMAN_SUCCESS )
        {
            echo "Code: " . $this->getClient()->returnCode() . "\t" . GEARMAN_TIMEOUT . "\n";
        }
    }

那个回声回来了

Method: doHighBackground Worker: leadposter Payload: 10930 Hash: 091878f5965e4a1de2992c607b3c562b240792a6

这是错误信息

["error":"Uecode\GearmanBundle\Gearman\Job":private]=>
  array(4) {
    ["attempts"]=>
    int(3)
    ["return_code"]=>
    int(47)
    ["error_no"]=>
    int(0)
    ["error"]=>
    string(103) "gearman_wait(GEARMAN_TIMEOUT) timeout reached, no servers were available -> libgearman/universal.cc:325"
  }
4

2 回答 2

0

解决了。

Connections werent persisting across methods... so, build a server pool, and connected to the servers just before running the job

于 2012-10-16T21:12:23.783 回答
0

If your gearmand is on another port, be sure AddServers knows, else will GEARMAN_TIMEOUT.

gearmand -d -p 4769

$worker->addServers(127.0.0.1:4769);

于 2019-10-30T19:50:14.317 回答