略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: GearmanWorker::addServers

2024-11-14

GearmanWorker::addServers

(PECL gearman >= 0.5.0)

GearmanWorker::addServersAdd job servers

说明

public GearmanWorker::addServers(string $servers = 127.0.0.1:4730): bool

Adds one or more job servers to this worker. These go into a list of servers that can be used to run jobs. No socket I/O happens here.

参数

servers

A comma separated list of job servers in the format host:port. If no port is specified, it defaults to 4730.

返回值

成功时返回 true, 或者在失败时返回 false

范例

示例 #1 Add two job servers

<?php

$worker
= new GearmanWorker(); 
$worker->addServers("10.0.0.1,10.0.0.2:7003");

?>

参见

add a noteadd a note

User Contributed Notes 1 note

up
0
matthew day
10 years ago
as of this note, the current released version of gearman doesn't really work so well to add multiple servers, although it's fixed in SVN

see: https://bugs.php.net/bug.php?id=59423

if i just add one server to my worker, it works just fine and sits and waits for a job to do

if I have more than 1 server in my worker, i get a timeout warning which causes the worker to generate a php notice and the while loop fails.

官方地址:https://www.php.net/manual/en/gearmanworker.addservers.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3