/** * {@inheritdoc} * * @throws \RuntimeException When another task is already running. */ public function run(InputInterface $input, OutputInterface $output) { // If successfully forked, exit now as the parenting process is done. if ($this->fork()) { $output->writeln('Forked into background.'); return 0; } return parent::run($input, $output); }
public function run(InputInterface $inputInterface, OutputInterface $outputInterface) { register_shutdown_function(array($this, 'terminate'), $inputInterface, $outputInterface); \Amp\run(function () use($inputInterface, $outputInterface) { \Amp\repeat(function () use($inputInterface, $outputInterface) { if ($leaking = $this->isLeaking()) { $this->getContainer()->get('logger')->alert('Memory leaked.', $leaking); } parent::run($inputInterface, $outputInterface); }, 1); $outputInterface->writeln('The command has <info>successfully</info> started.'); }); }
public function run(InputInterface $input, OutputInterface $output) { $start = new \DateTime(); $output->writeln('<comment>' . $this->getName() . '</comment> started at <info>' . $start->format('Y-m-d H:i:s') . '</info>'); $msg = ''; try { $return = parent::run($input, $output); } catch (\Exception $ex) { $msg = '<error>FAILURE of </error>'; $this->onError($input, $output, $ex); } $end = new \DateTime(); $duration = Carbon::instance($start)->diffInSeconds(Carbon::instance($end)); $msg .= '<comment>' . $this->getName() . '</comment> ended at <info>' . $end->format('Y-m-d H:i:s') . '</info>. Duration is <info>' . $duration . '</info> seconds.'; $this->displayMemory($output); $output->writeln($msg); if (isset($ex)) { $this->dispatch(CommandEvents::ERROR, new CommandEvent($this, array('exception' => $ex))); throw $ex; } $this->dispatch(CommandEvents::TERMINATE, new CommandEvent($this)); return $return; }
/** * @param InputInterface $inputInterface * @param OutputInterface $outputInterface * @return int|void * @throws \Keboola\ProvisioningBundle\Provisioning\Exception */ public function run(InputInterface $inputInterface, OutputInterface $outputInterface) { if ($this->getContainer()->hasParameter("maintenance.status") && $this->getContainer()->getParameter("maintenance.status") == true) { throw new Exception("Maintenance"); } return parent::run($inputInterface, $outputInterface); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int * * @see Symfony\Component\Console\Command\Command::run() */ public function run(InputInterface $input, OutputInterface $output) { // Force the creation of the synopsis before the merge with the app definition $this->getSynopsis(); // Add the signal handler if (function_exists('pcntl_signal')) { // Enable ticks for fast signal processing declare (ticks=1); pcntl_signal(SIGTERM, array($this, 'handleSignal')); pcntl_signal(SIGINT, array($this, 'handleSignal')); } // And now run the command return parent::run($input, $output); }
/** * Override framework function to add pre and post hooks around the parent functionality * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return int The command exit code * * @throws \Exception * @throws BaseCommandException * * @see setCode() * @see execute() */ public function run(InputInterface $input, OutputInterface $output) { $this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN); $this->preRun($output); $this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN); $exitCode = parent::run($input, $output); if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) { if ($this->getRuntimeConfig()->getExecutionPhase() == RuntimeConfig::PHASE_INITIALIZE_FAILED) { throw new BaseCommandException('It appears that you tried to continue execution despite the initialization ' . 'of the BaseCommand failing. This is a very dangerous idea as the behaviour is undefined'); } else { throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?'); } } $this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN); $this->postRun($input, $output, $exitCode); return $exitCode; }
public function run(InputInterface $input, OutputInterface $output) { $this->output = $output; $result = parent::run($input, $output); return $result; }
/** * Runs a command and returns a response if there was an error. * * @param ContainerAwareCommand $command * @param InputInterface|null $input * * @return Response|null */ private function runCommand(ContainerAwareCommand $command, InputInterface $input = null) { if (null === $input) { $input = new ArgvInput([]); } $output = new BufferedOutput(OutputInterface::VERBOSITY_NORMAL, true); $command->setContainer($this->container); $status = $command->run($input, $output); if ($status > 0) { return $this->render('console.html.twig', ['output' => $output->fetch()]); } return null; }
/** * Override framework function to add pre and post hooks around the parent functionality * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return int The command exit code * * @throws \Exception * @throws BaseCommandException * * @see setCode() * @see execute() */ public function run(InputInterface $input, OutputInterface $output) { if (is_null($this->runtimeConfig)) { throw new BaseCommandException("If you override the 'configure()' function, you need to call parent::configure()" . " in your overridden method in order for the BaseCommand to function correctly"); } $this->advanceExecutionPhase(RuntimeConfig::PHASE_PRE_RUN); $this->preRun($output); $this->advanceExecutionPhase(RuntimeConfig::PHASE_RUN); $exitCode = parent::run($input, $output); if ($this->getRuntimeConfig()->getExecutionPhase() !== RuntimeConfig::PHASE_POST_INITIALISE) { throw new BaseCommandException('BaseCommand not initialized. Did you override the initialize() function ' . 'without calling parent::initialize() ?'); } $this->advanceExecutionPhase(RuntimeConfig::PHASE_POST_RUN); $this->postRun($input, $output, $exitCode); return $exitCode; }