Example #1
0
 public function run(JobInterface $job, $maxProcesses)
 {
     $collection = new JobCollection();
     $collection->addJob($job);
     $worker = $this->factory->getWorker($collection, $maxProcesses);
     $worker->setMode(Worker::MODE_SERIAL);
     $worker->setStopIfNoJob();
     $worker->work();
 }
 protected function runWorkerProcess($routeName)
 {
     $worker = $this->workerFactory->getOneRouteWorker($this->brokerName, $routeName, $this->processesPerWorker);
     $worker->setMode($this->mode);
     $worker->setStopIfNoJob(true);
     $fork = $this->processManager->fork(function () use($worker) {
         $worker->work();
     })->afterExit(function () use($routeName) {
         unset($this->processes[$routeName]);
     });
     $this->processes[$routeName] = $fork;
 }