Пример #1
0
 function it_does_not_clean_up_workers_on_another_host(SystemInterface $system, $workerRegistry, WorkerInterface $localWorker, WorkerInterface $remoteWorker, Process $localProcess, Process $remoteProcess)
 {
     $system->getCurrentPid()->willReturn(6545);
     $system->getHostname()->shouldBeCalled()->willReturn('bar.resque.com');
     $workerRegistry->all()->shouldBeCalled()->willReturn([$localWorker, $remoteWorker]);
     $localWorker->getProcess()->shouldBeCalled()->willReturn($localProcess);
     $remoteWorker->getProcess()->shouldBeCalled()->willReturn($remoteProcess);
     $localWorker->getHostname()->shouldBeCalled()->willReturn('bar.resque.com');
     $remoteWorker->getHostname()->shouldBeCalled()->willReturn('my.other.host');
     $localProcess->getPid()->willReturn(1);
     $remoteProcess->getPid()->willReturn(1);
     $workerRegistry->deregister($localWorker)->shouldBeCalled();
     $workerRegistry->deregister($remoteWorker)->shouldNotBeCalled();
     $this->pruneDeadWorkers();
 }
Пример #2
0
 /**
  * Deregister on worker exit.
  *
  * @param WorkerInterface $worker The worker to wait for exit and then deregister.
  * @throws ResqueRuntimeException when $worker fails to exit cleanly.
  * @return void
  */
 public function deregisterOnWorkerExit(WorkerInterface $worker)
 {
     $process = $worker->getProcess();
     $process->wait();
     if ($process->isCleanExit()) {
         $this->registry->deregister($worker);
     } else {
         throw new ResqueRuntimeException(sprintf('Foreman error with worker %s wait on pid %d', $worker->getId(), $process->getPid()));
     }
 }