public function pruneDeadWorkers()
    {
        $workerPids = $this->getLocalWorkerPids();
        $workers = $this->registry->all(); // @todo Maybe findWorkersForHost($hostname) ?
        $hostname = $this->system->getHostname();
        foreach ($workers as $worker) {
            if ($worker instanceof WorkerInterface) {
                $isNotOnCurrentHost = $worker->getHostname() != $hostname;
                $isCurrentlyRunning = in_array($worker->getProcess()->getPid(), $workerPids);
                $isCurrentProcess = $worker->getProcess()->getPid() == $this->system->getCurrentPid();

                if ($isNotOnCurrentHost || $isCurrentlyRunning || $isCurrentProcess) {
                    continue;
                }

                $this->logger->warning('Pruning dead worker {worker}', array('worker' => $worker));
                $this->registry->deregister($worker);
            }
        }
    }
public function pruneDeadWorkers()
    {
        $workerPids = $this->getLocalWorkerPids();
        $workers = $this->registry->all(); // @todo Maybe findWorkersForHost($hostname) ?
        $hostname = $this->system->getHostname();
        foreach ($workers as $worker) {
            if ($worker instanceof WorkerInterface) {
                $isNotOnCurrentHost = $worker->getHostname() != $hostname;
                $isCurrentlyRunning = in_array($worker->getProcess()->getPid(), $workerPids);
                $isCurrentProcess = $worker->getProcess()->getPid() == $this->system->getCurrentPid();

                if ($isNotOnCurrentHost || $isCurrentlyRunning || $isCurrentProcess) {
                    continue;
                }

                $this->logger->warning('Pruning dead worker {worker}', array('worker' => $worker));
                $this->registry->deregister($worker);
            }
        }
    }
public function pruneDeadWorkers ( ) { $ workerPids = $ this -> getLocalWorkerPids ( ) ; $ workers = $ this -> registry -> all ( ) ; // @todo Maybe findWorkersForHost($hostname) ? $ hostname = $ this -> system -> getHostname ( ) ; foreach ( $ workers as $ worker ) { if ( $ worker instanceof WorkerInterface ) { $ isNotOnCurrentHost = $ worker -> getHostname ( ) != $ hostname ; $ isCurrentlyRunning = in_array ( $ worker -> getProcess ( ) -> getPid ( ) , $ workerPids ) ; $ isCurrentProcess = $ worker -> getProcess ( ) -> getPid ( ) == $ this -> system -> getCurrentPid ( ) ; if ( $ isNotOnCurrentHost || $ isCurrentlyRunning || $ isCurrentProcess ) { continue ; } $ this -> logger -> warning ( 'Pruning dead worker {worker}' , array ( 'worker' => $ worker ) ) ; $ this -> registry -> deregister ( $ worker ) ; } } }
Prune dead workers.

Look for any workers which should be running on this server and if
they're not, remove them from Redis.

This is a form of garbage collection to handle cases where the
server may have been killed and the workers did not exit gracefully
and therefore leave state information in Redis.

@return void
Prune dead workers .