CakeFest 2024: The Official CakePHP Conference

GearmanWorker::addServers

(PECL gearman >= 0.5.0)

GearmanWorker::addServersAñade servidores de trabajo

Descripción

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

Añade uno o más servidores de trabajos a este trabajador. Se añaden a una lista de servidores que pueden ser usados para ejecutar trabajos. No se realiza ninguna acción de entrada/salida con sockets.

Parámetros

servers

Una lista de servidores de trabajo separadas por comas en el formato servidor:puerto. Si no se especifica puerto, se usa el puerto por defecto 4730.

Valores devueltos

Devuelve true en caso de éxito o false en caso de error.

Ejemplos

Ejemplo #1 Añade dos servidores de trabajo

<?php

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

?>

Ver también

add a note

User Contributed Notes 1 note

up
0
matthew day
12 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.
To Top