/** * Execute Symfony2 command * * @param string $command Command name (for example, "cache:clear") * @param array $params [optional] Additional command parameters, like "--force" etc * @return int an executed command exit code * @throws \Exception * @throws \RuntimeException */ protected function runCommand($command, $params = array()) { $application = $this->getApplication(); $output = $this->getOutput(); $commandExecutor = new CommandExecutor($application->getKernel()->getEnvironment(), $output, $application); $output->writeln(''); $output->writeln(sprintf('[%s] Launching "%s" command', date('Y-m-d H:i:s'), $command)); error_log(sprintf('[%s] Launching "%s" command', date('Y-m-d H:i:s'), $command)); error_log($command); error_log(print_r($params, 1)); // Add error_log in vendor/symfony/symfony/src/Symfony/Component/Console/Application.php run() function $mem = (int) memory_get_usage() / (1024 * 1024); $time = time(); $result = null; try { $commandExecutor->runCommand($command, $params); $result = $commandExecutor->getLastCommandExitCode(); } catch (\RuntimeException $ex) { $result = $ex; error_log($ex->getMessage()); } $output->writeln(''); $output->writeln(sprintf('Command "%s" executed in %u second(s), memory usage: %.2fMb', $command, time() - $time, (int) memory_get_usage() / (1024 * 1024) - $mem)); $output->writeln(''); // check for any error if ($result instanceof \RuntimeException) { throw $result; } return $result; }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $force = $input->getOption('force'); if ($force) { $commandExecutor = new CommandExecutor($input->hasOption('env') ? $input->getOption('env') : null, $output, $this->getApplication()); $commandExecutor->setDefaultTimeout($input->getOption('timeout')); $commandExecutor->runCommand('oro:migration:load', array('--force' => true))->runCommand('oro:migration:data:load', array('--no-interaction' => true)); } else { $output->writeln('<comment>ATTENTION</comment>: Database backup is highly recommended before executing this command.'); $output->writeln(' Please make sure that application cache is up-to-date before run this command.'); $output->writeln(' Use <info>cache:clear</info> if needed.'); $output->writeln(''); $output->writeln('To force execution run command with <info>--force</info> option:'); $output->writeln(sprintf(' <info>%s --force</info>', $this->getName())); } }
/** * @inheritdoc */ protected function execute(InputInterface $input, OutputInterface $output) { $force = $input->getOption('force'); if ($force) { $commandExecutor = new CommandExecutor($input->hasOption('env') ? $input->getOption('env') : null, $output, $this->getApplication()); $commandExecutor->setDefaultTimeout($input->getOption('timeout')); $commandExecutor->runCommand('oro:migration:load', array('--process-isolation' => true, '--force' => true))->runCommand('oro:migration:data:load', array('--process-isolation' => true))->runCommand('assets:install')->runCommand('assetic:dump'); //->runCommand('fos:js-routing:dump', array('--target' => 'web/js/routes.js')) //->runCommand('oro:localization:dump') //->runCommand('oro:translation:dump') //->runCommand('oro:requirejs:build', array('--ignore-errors' => true)); } else { $output->writeln('<comment>ATTENTION</comment>: Database backup is highly recommended before executing this command.'); $output->writeln(' Please make sure that application cache is up-to-date before run this command.'); $output->writeln(' Use <info>cache:clear</info> if needed.'); $output->writeln(''); $output->writeln('To force execution run command with <info>--force</info> option:'); $output->writeln(sprintf(' <info>%s --force</info>', $this->getName())); } }
/** * @param CommandExecutor $commandExecutor * @param InputInterface $input * @param OutputInterface $output * @return InstallCommand */ protected function finalStep(CommandExecutor $commandExecutor, InputInterface $input, OutputInterface $output) { $output->writeln('<info>Preparing application.</info>'); $input->setInteractive(false); $commandExecutor->runCommand('assets:install', array('target' => './', '--symlink' => true, '--relative' => true))->runCommand('assetic:dump', array('--process-isolation' => true)); // run installer scripts $this->processInstallerScripts($output, $commandExecutor); $this->updateInstalledFlag(date('c')); // clear the cache set installed flag in DI container $commandExecutor->runCommand('cache:clear', array('--process-isolation' => true)); $output->writeln(''); return $this; }