Exemplo n.º 1
0
 /**
  * @param JobInterface $job
  * @param $maxProcesses
  * @return \queue\process\Fork
  */
 public function runAsync(JobInterface $job, $maxProcesses)
 {
     $fork = $this->processManager->fork(function () use($job, $maxProcesses) {
         $this->run($job, $maxProcesses);
     });
     return $fork;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 public function runTask(TaskInterface $task)
 {
     $this->processManager->fork(function () use($task) {
         $this->isMasterProcess = false;
         $task->run();
     })->afterExit(function (Fork $fork) use($task) {
         $job = $task->getJob();
         if ($fork->getStatus() != 0) {
             $task->setFailed();
         }
         $task->setFinish();
         if ($job->getStatus() != JobInterface::IN_PROGRESS) {
             unset($this->jobs[$job->getId()]);
         }
     });
 }