0
gearman을 실행하면 단일 서버에서 3 명의 작업자가 제대로 작동하지만 4 번째 PHP 코드가 제대로 작동하지만 새로운 작업자를 감지 할 수 없으며 작업 대기열을 지우지 않습니다.동일한 서버에서 3 명 이상의 기어맨 작업자를 실행할 수 없습니다
protected function createWorker()
{
$this->worker = new \GearmanWorker();
$config = $this->app->config->job_remote;
$this->worker->addServer($config['host'], $config['port']);
return $this->worker;
}
public function listen($eventType, $callback)
{
if (!($this->worker instanceof \GearmanWorker)){
$this->worker = $this->createWorker();
}
$this->worker->addFunction($eventType, $callback);
return $this->worker;
}
public function doWork($worker)
{
if (!($worker instanceof \GearmanWorker)){
$worker = $this->createWorker();
}
$this->worker = $worker;
while (1) {
$this->worker->work();
$this->app->log->debug($this->worker->returnCode());
if ($this->worker->returnCode() != \GEARMAN_SUCCESS) {
break;
}
}
}
우선이 방법 다음 'doWork'방법
클라이언트 측 코드 '들을'호출 오전 : GearmanManager 당신은 어떤 어떤 개까지 실행할 수 없습니다 사용
protected function createClient()
{
$this->client = new \GearmanClient();
$config = $this->app->config->job_remote;
$this->client->addServer($config['host'], $config['port']);
return $this->client;
}
public function addTask($eventType, array $params)
{
if (!($this->client instanceof \GearmanClient)){
$this->client = $this->createClient();
}
// add single task in queue
$this->client->addTaskBackground($eventType, serialize($params));
// Run task
$this->client->runTasks();
}
당신의 코드는 어디에 있습니까 .. 무엇을 시도 했습니까 –
코드를 추가했습니다. –
클라이언트 코드는 어디에 있습니까 ??? 당신이 일자리를 할당 한 곳에서. –