Ejemplo n.º 1
0
 private function start(ProcessManager $processManager, JobExecutor $jobExecutor)
 {
     if ($this->pid !== null) {
         return;
     }
     $this->pid = $processManager->forkChild(sprintf('Event processing job `%s`', $this->name));
     if ($this->pid === 0) {
         // Start the job in forked process
         $this->run($jobExecutor);
     } else {
         $processManager->onChildExited($this->pid, function ($exitCode) {
             $this->pid = null;
             // Disable job if it has failed
             if ($exitCode !== 0) {
                 $this->enabled = false;
             }
         });
     }
 }