protected function execute(InputInterface $input, OutputInterface $output)
{
$output = new SymfonyStyle($input, $output);
$workerCount = $input->getOption('count');
$queues = $this->createQueues($input->getArgument('queues'));
$output->write($queues);
// This method of worker setup requires an array of queues
if (!is_array($queues)) {
throw new \Exception("Queues not initialized correctly");
}
$workers = array();
for ($i = 0; $i < $workerCount; ++$i) {
$worker = $this->workerFactory->createWorker();
$workerProcess = $this->workerFactory->createWorkerProcess($worker);
foreach ($queues as $queue) {
$worker->addQueue($queue);
}
$workers[] = $workerProcess;
}
$this->foreman->pruneDeadWorkers();
$this->foreman->work($workers, $input->getOption('wait'));
echo sprintf('%d workers attached to the %s queues successfully started.', count($workers), implode($queues, ','));
// echo sprintf(
// 'Workers (%s)',
// implode(', ', $workers)
// );
}