This method is called before runTransient()

@param InputInterface  $input  is the input interface
@param OutputInterface $output is the output interface

@return $this
977674
public function before(InputInterface $input=null,
        OutputInterface $output=null
    ) {
        $this->pwd          = getcwd();
        $this->output       = $output;
        $this->_storeName   = $input->getOption('storage');
        $this->loadOutputStyles();
        $this->setCurrentEnvironment($this->getDefaultCurrentEnvironment());
        $this->loadEnvironments();
        return $this;
    }
1132085
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->requireConfig();

        $utils = new Utils();
        $output->writeln('Starting <fg=blue>Magallanes</>');
        $output->writeln('');

        try {
            $this->runtime->setEnvironment($input->getArgument('environment'));

            if (!$this->runtime->getEnvOption('releases', false)) {
                throw new RuntimeException('Releases are not enabled', 70);
            }

            $output->writeln(sprintf('    Environment: <fg=green>%s</>', $this->runtime->getEnvironment()));
            $this->log(sprintf('Environment: %s', $this->runtime->getEnvironment()));

            if ($this->runtime->getConfigOption('log_file', false)) {
                $output->writeln(sprintf('    Logfile: <fg=green>%s</>', $this->runtime->getConfigOption('log_file')));
            }

            $output->writeln('');

            $hosts = $this->runtime->getEnvOption('hosts');
            if (!is_array($hosts) && !$hosts instanceof \Countable) {
                $hosts = [];
            }
            if (count($hosts) == 0) {
                $output->writeln('No hosts defined');
                $output->writeln('');
            } else {
                $hostPath = rtrim($this->runtime->getEnvOption('host_path'), '/');

                foreach ($hosts as $host) {
                    $this->runtime->setWorkingHost($host);

                    // Get List of Releases
                    $cmdListReleases = sprintf('ls -1 %s/releases', $hostPath);

                    /** @var Process $process */
                    $process = $this->runtime->runRemoteCommand($cmdListReleases, false);
                    if (!$process->isSuccessful()) {
                        throw new RuntimeException(sprintf('Unable to retrieve releases from host "%s"', $host), 80);
                    }

                    $releases = [];
                    if (trim($process->getOutput()) != '') {
                        $releases = explode(PHP_EOL, trim($process->getOutput()));
                        rsort($releases);
                    }

                    if (count($releases) == 0) {
                        $output->writeln(sprintf('    No releases available on host <fg=black;options=bold>%s</>:', $host));
                    } else {
                        // Get Current Release
                        $cmdCurrentRelease = sprintf('readlink -f %s/current', $hostPath);

                        /** @var Process $process */
                        $process = $this->runtime->runRemoteCommand($cmdCurrentRelease, false);
                        if (!$process->isSuccessful()) {
                            throw new RuntimeException(sprintf('Unable to retrieve current release from host "%s"', $host), 85);
                        }

                        $currentReleaseId = explode('/', trim($process->getOutput()));
                        $currentReleaseId = $currentReleaseId[count($currentReleaseId) - 1];

                        $output->writeln(sprintf('    Releases on host <fg=black;options=bold>%s</>:', $host));

                        foreach ($releases as $releaseId) {
                            $releaseDate = $utils->getReleaseDate($releaseId);

                            $output->write(sprintf('        Release ID: <fg=magenta>%s</> - Date: <fg=black;options=bold>%s</> [%s]',
                                $releaseId,
                                $releaseDate->format('Y-m-d H:i:s'),
                                $utils->getTimeDiff($releaseDate)
                            ));

                            if ($releaseId == $currentReleaseId) {
                                $output->writeln(' <fg=red;options=bold>[current]</>');
                            } else {
                                $output->writeln('');
                            }
                        }
                    }

                    $this->runtime->setWorkingHost(null);
                    $output->writeln('');
                }
            }
        } catch (RuntimeException $exception) {
            $output->writeln(sprintf('<error>%s</error>', $exception->getMessage()));
            $this->statusCode = $exception->getCode();
        }

        $output->writeln('Finished <fg=blue>Magallanes</>');

        return $this->statusCode;
    }
646660
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
        $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
        $errOutput->setVerbosity(OutputInterface::VERBOSITY_NORMAL);

        $batchSize = NumberUtils::bound($input->getOption('batch-size'), 1, 2000);
        $batchDelay = NumberUtils::bound($input->getOption('batch-delay'), 10, 600000);
        $context = json_decode($input->getOption('context') ?: '{}', true);
        $context['tenant_id'] = (string)$input->getOption('tenant-id');
        $context['exporting'] = true;
        $qname = $input->getArgument('qname') ? SchemaQName::fromString($input->getArgument('qname')) : null;
        $context['exporting_all'] = null === $qname;

        $i = 0;

        $receiver = function (Node $node) use ($errOutput, $batchSize, $batchDelay, &$i) {
            ++$i;

            try {
                echo json_encode($node) . PHP_EOL;
            } catch (\Exception $e) {
                $errOutput->writeln($e->getMessage());
            }

            if (0 === $i % $batchSize) {
                if ($batchDelay > 0) {
                    usleep($batchDelay * 1000);
                }
            }
        };

        foreach ($this->getSchemasUsingMixin(NodeV1Mixin::create(), (string)$qname ?: null) as $schema) {
            $this->ncr->pipeNodes($schema->getQName(), $receiver, $context);
        }
    }
1363883
public function doRun(InputInterface $input, OutputInterface $output)
  {
    $this->input = $input;
    $this->output = $output;
    $this->committedFiles = $this->extractCommittedFiles();
    $this->allFiles = $this->extractTopLevelFiles();
    $this->intersectFiles = array_intersect($this->allFiles, $this->committedFiles);
    if ($this->getConfiguration()->execute()) {
      $this->parseFiles();
    }
    else {
      $this->destroy();
    }
  }
980225
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $this->setIO($input, $output);
        parent::doRun($input, $output);
    }
495302
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $logger = $this->getLogger();

        if (!$this->lock()) {
            $output->writeln('<comment>The command is already running in another process.</comment>');
            $logger->warning('Command is already running.');
        } else {
            try {
                $logger->info('Started export in command.');

                $orderVisitor = $this->getOrders();

                $this->getExporter()->exportOrders($orderVisitor, $this->getProgressBar($output, count($orderVisitor)));

                $logger->info('Finished export in command.');
            } catch (Exception $exc) {
                $logger->error('Stopped export in command.', ['exception' => $exc]);
            }
        }
    }
509474
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        if (!$this->canRunAsRoot && $this->isRunningAsRoot() === true) {
            $this->confirmRunningAsRoot($input, $output);
        }
    }
708171
public function daemon(InputInterface $input, OutputInterface $output)
    {
        // Init services
        $container = $this->getContainer();

        if (is_null($this->dispatcher) && $container->has('event_dispatcher')) {
            $this->dispatcher = $this->getContainer()->get('event_dispatcher');
        }

        $this->loop = $container->get('m6_daemon_bundle.event_loop');

        // Last configuration
        $this->configureEvents();

        // Options
        $this->setShutdownOnException($input->hasOption('shutdown-on-exception') ? $input->getOption('shutdown-on-exception') : false);
        $this->setMemoryMax($input->hasOption('memory-max') ? $input->getOption('memory-max') : -1);
        $this->setShowExceptions($input->hasOption('show-exceptions') ? $input->getOption('show-exceptions') : false);

        if ($input->hasOption('run-once') && (bool) $input->getOption('run-once')) {
            $this->setLoopMax(1);
        } else {
            if ($input->hasOption('run-max')) {
                $this->setLoopMax($input->getOption('run-max'));
            }
        }

        // Ok starting...
        $this->dispatchEvent(DaemonEvents::DAEMON_START);

        // Setup
        $this->setup($input, $output);

        // General loop
        $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_BEGIN);

        // First tick
        $this->loop->futureTick(function () use ($input, $output) {
            $this->loop($input, $output);
        });

        // Go !
        $this->loop->run();

        $this->dispatchEvent(DaemonEvents::DAEMON_LOOP_END);

        // Prepare for shutdown
        $this->tearDown($input, $output);
        $this->dispatchEvent(DaemonEvents::DAEMON_STOP);

        return $this->returnCode;
    }
652896
protected function execute(InputInterface $input, OutputInterface $output)
  {
    if(empty($this->host))
    {
      if($this->cubexLocalSubDomain)
      {
        $this->host = $this->cubexLocalSubDomain . '.cubex-local.com';
      }
      else
      {
        $this->host = $this->debug ? '0.0.0.0' : 'localhost';
      }
    }

    if($this->port === null)
    {
      $this->port = 8888;
      $this->useNextAvailablePort = true;
    }

    if($this->useNextAvailablePort)
    {
      for($i = 0; $i < 100; $i++)
      {
        if($this->_isPortAvailable($this->port))
        {
          break;
        }
        $this->port++;
      }
    }

    if(ValueAs::bool($this->showfig))
    {
      $output->write(Figlet::create('PHP WEB', 'ivrit'));
      $output->write(Figlet::create('SERVER', 'ivrit'));
    }

    return $this->_runCommand($this->_buildCommand($output));
  }
120168
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->transifexconfig = $input->getOption('transifex-config');
        $this->setProject($input, $output);
        $this->setPrefix($input, $output);
        $this->setXliffDirectory($input, $output);
        $this->setContaoLanguageDirectory($input, $output);
        $this->baselanguage = $input->getOption('base-language');
        $this->skipFiles    = $input->getOption('skip-files') ? explode(',', $input->getOption('skip-files')) : null;

        if (!$this->skipFiles) {
            $this->skipFiles = $this->getTransifexConfigValue('/skip_files') ?: array();
        } else {
            // Make sure it is an array.
            $this->skipFiles = array();
        }

        $activeLanguages = array();
        if (($langs = $input->getArgument('languages')) != 'all') {
            $activeLanguages = explode(',', $langs);
        }

        $this->determineLanguages($output, $this->getLanguageBasePath(), $activeLanguages);
    }
1341932
public function run(InputInterface $input = null, OutputInterface $output = null)
    {
        $this->boot();

        return $this->container['console']->run($input, $output);
    }
169857
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);

        $this
            ->entityTranslationEventDispatcher
            ->dispatchTranslatorWarmUp();

        $this->finishCommand($output);
    }
105744
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->Selftest($input, $output);
        $this->Ping($input, $output);
        $this->Connect($input, $output);
    }
1109651
protected function initialize(InputInterface $input, OutputInterface $output)
    {
        $this->input = $input;
        $this->output = $output;
        $this->formatter = $this->getHelper('formatter');
        $this->fs = new Filesystem();
    }
251064
public function doRun(InputInterface $input, OutputInterface $output)
    {
        $name = $this->getCommandName($input);
        $result = true;

        if (isset($this->_callbacks['before'][$name])){

            $callbacks = $this->_callbacks['before'][$name];

            foreach($callbacks as $callback) {

                $result = call_user_func_array($callback, array($input, $output));

                if ($result === false) {
                    break;
                }
            }
        }

        if ($result !== false) {

            parent::doRun($input, $output);

            if (isset($this->_callbacks['after'][$name])) {

                $callbacks = $this->_callbacks['after'][$name];

                foreach ($callbacks as $callback) {
                    call_user_func_array($callback, array($input, $output));
                }
            }
        }
    }
850737
protected function execute(InputInterface $input, OutputInterface $output)
    {
        return $this->getRunner($input, $output)->run() ? 0 : -1;
    }
761302
public function execute(InputInterface $input, OutputInterface $output)
    {
        $runner = $this->commandDefinition->getRunner();
        $runner();
    }