/** * {@inheritDoc} */ public function createWorkerFromId($workerId) { if (false === strpos($workerId, ":")) { return null; } list($hostname, $pid, $queues) = explode(':', $workerId, 3); $queues = explode(',', $queues); if (!$queues) { throw new ResqueRuntimeException(sprintf("Invalid worker ID \"%s\"", $workerId)); } $worker = new Worker($this->jobInstanceFactory, $this->eventDispatcher); $worker->setHostname($hostname); $process = new Process($pid); // @todo When worker is on another host, Process is over kill. $worker->setProcess($process); foreach ($queues as $queue) { $worker->addQueue($this->queueFactory->createQueue($queue)); // @todo what about wildcard queues? :( } return $worker; }
/** * @expectedException \Resque\Component\Core\Exception\ResqueRuntimeException */ public function testCannotSetCurrentJobIfNotNull() { $this->worker->setCurrentJob(new Job()); $this->worker->setCurrentJob(new Job()); }