setName('run:parallel') ->setDescription('Run in parallel from the directory of the repo using a ini file.') ->setHelp('This command allows you to tag and change the required code on the composer.json file...') ->addArgument('ini_file', InputArgument::REQUIRED, 'The ini file from where to get the source code config.') ->addArgument('cmd', InputArgument::REQUIRED, 'the command to run in parallel'); } protected function execute(InputInterface $input, OutputInterface $output) { $file = $input->getArgument("ini_file"); $initial_dir = getcwd(); $realpath = realpath($file); $dirname = dirname($realpath); if (!chdir($dirname)) { throw new \Exception("Can't change working directory to " . $dirname); } $content = parse_ini_file($realpath, true); $command = $input->getArgument("cmd"); $p_list = array(); foreach ($content as $sec => $conf) { chdir($dirname . "/" . $sec); $output->writeln($sec . "-> " . $command); $process = new Process($command); //$process->setTimeout(600); //$process->setIdleTimeout(6); $p_list[$sec] = $process; $process->start(); } foreach ($content as $sec => $conf) { $process = $p_list[$sec]; $process->wait(); $output->writeln("" . $sec . ""); $output->write($process->getOutput() . "\n"); } chdir($initial_dir); } }