Comment 6 for bug 802850

Revision history for this message
Artur Bodera (abodera) wrote :

Number of workers is always <20

Each worker listens for max 2h, then shuts itself down and a new process is spawned (not a fork, completely new php shell process).

$gmworker = new GearmanWorker();
$gmworker->addOptions(GEARMAN_WORKER_GRAB_UNIQ);
$gmworker->setTimeout(5000);
$gmworker->addFunction($funcName, array($this,'workGearman'))

main loop (with fat removed):

while(
!$this->_signal &&
(
   @$gmworker->work() ||
   $gmworker->returnCode() == GEARMAN_TIMEOUT
) && !$this->_signal
){
   // nothing unusual happened, run another loop iteration
   $db->closeConnection();
   $log->debug('Waiting for jobs...');
}