/**
  * Add regular workers.  Theses are workers that can have multiple instances running
  *
  * @param $env
  */
 protected function addWorkers($env)
 {
     $phpBinary = PHP_BINARY;
     $resourceMapper = $this->getContainer()->get('voryx.thruway.resource.mapper');
     $mappings = $resourceMapper->getAllMappings();
     foreach ($mappings as $workerName => $mapping) {
         $this->output->writeln("Adding workers: {$workerName}");
         $workerAnnotation = $resourceMapper->getWorkerAnnotation($workerName);
         $numprocs = $workerAnnotation ? $workerAnnotation->getMaxProcesses() : 1;
         $cmd = "{$phpBinary} {$this->getContainer()->get('kernel')->getRootDir()}/console --env={$env} thruway:worker:start {$workerName} 0";
         $command = new Command($workerName, $cmd);
         $command->setMaxInstances($numprocs);
         $this->processManager->addCommand($command);
     }
 }
Пример #2
0
 /**
  * @param Command $command
  * @throws \Exception
  */
 public function addCommand(Command $command)
 {
     $this->commands[$command->getName()] = $command;
     $command->setLoop($this->getLoop());
     $command->startProcess();
 }