コード例 #1
0
 /**
  * @param WorkerConfig[] $workers
  * @param VMConfig[]     $VMConfigs
  *
  * @throws \Exception
  */
 protected function fillStatus($workers, $VMConfigs)
 {
     foreach ($VMConfigs as $host => $VMConfig) {
         $hostWorkers = $this->loadStatus($VMConfig);
         $VMConfig = $VMConfigs[$host];
         foreach ($hostWorkers as $workerData) {
             $search = preg_match('~^([^\\:]+)\\:(.+)_([0-9]{2})$~', $workerData['name'], $match);
             if ($search) {
                 /** @var WorkerConfig $worker */
                 foreach ($workers as $worker) {
                     if ($worker->getName() === $match[2]) {
                         $workerProcess = new WorkerProcess($workerData['name'], $workerData['status'], $workerData['pid'], $workerData['uptime']);
                         $worker->addProcess($workerProcess->setVMConfig($VMConfig))->setMaxWorkerCount(count($worker->getProcess()));
                         break;
                     }
                 }
             }
         }
     }
     foreach ($workers as $worker) {
         if (null === $worker->getProcess()) {
             throw new \Exception(sprintf('Worker %s don\'t have any process', $worker->getName()));
         }
     }
 }
コード例 #2
0
 /**
  * @param WorkerProcess $process
  */
 protected function startProcess(WorkerProcess $process)
 {
     $VMConfig = $process->getVMConfig();
     SupervisorManager::init($VMConfig)->runCommand(sprintf('start %s', $process->getProcessName()));
     $process->setStatus(WorkerProcess::STATUS_RUNNING);
 }