public function work() { $identity = $this->identify(); $this->logger->notice(sprintf('%s waiting for work on queue(s) [%s]', $identity, join(', ', $this->queues))); for (;;) { $job = $this->metro->pop($this->queues, $this); if (null !== $job) { $jobHandler = $this->metro->createTaskLogHander($job->getId()); $this->logger->pushHandler($jobHandler); $this->logger->pushProcessor(function ($record) use($job) { $record['extra']['job_id'] = $job->getId(); return $record; }); $this->workOn($job, $jobHandler); $this->logger->popHandler(); $this->logger->popProcessor(); } if ($this->interval <= 0) { return; } if (null === $job) { if ($this->drainMode) { $this->logger->notice(sprintf('%s exiting because all queues are empty', $identity)); return; } usleep($this->interval * 1000.0); } } }