Example #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Hello Terra!');
     // Ask for an app and environment.
     $this->getApp($input, $output);
     $this->getEnvironment($input, $output);
     $environment_name = $this->environment->name;
     $app_name = $this->app->name;
     $environment_factory = new EnvironmentFactory($this->environment, $this->app);
     $environment_factory->writeConfig();
     $current_scale = $environment_factory->getScale();
     $output->writeln("Scaling Environment <comment>{$app_name} {$environment_name}</comment>...");
     $output->writeln("Current scale: <comment>{$current_scale}</comment>");
     // If no scale ask for scale.
     if (empty($scale)) {
         $question = new Question('How many app containers? ');
         $helper = $this->getHelper('question');
         $scale = $helper->ask($input, $output, $question);
     }
     $output->writeln("Target scale: <comment>{$scale}</comment>");
     $environment_factory->scale($scale);
     $output->writeln("Environment <comment>{$app_name} {$environment_name}</comment> scaled to <info>{$scale}</info>");
     // Output the new URL.
     $local_url = 'http://' . $environment_factory->getHost() . ':' . $environment_factory->getPort();
     $output->writeln('<info>Environment enabled!</info>  Available at http://' . $environment_factory->getUrl() . ' and ' . $local_url);
 }
Example #2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln('Hello Terra!');
     // If there are no apps, return
     if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) {
         $output->writeln('<comment>There are no apps!</comment>');
         $output->writeln('Use the command <info>terra app:add</info> to add your first app.');
         return;
     }
     $helper = $this->getHelper('question');
     $app_name = $input->getArgument('app_name');
     $environment_name = $input->getArgument('environment_name');
     $scale = $input->getArgument('scale');
     // If no name specified provide options
     if (empty($app_name)) {
         $question = new ChoiceQuestion('Which app? ', array_keys($this->getApplication()->getTerra()->getConfig()->get('apps')), null);
         $app_name = $helper->ask($input, $output, $question);
     }
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     if (empty($app)) {
         $output->writeln('<error>No app by that name!</error>');
         $output->writeln('Use the command <info>terra app:add</info> to add your first app.');
         return;
     }
     // If no environments:
     if (count($app['environments']) == 0) {
         $output->writeln('<comment>There are no environments!</comment>');
         $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.');
         return;
     }
     // If no environment name specified provide options
     if (empty($environment_name)) {
         $question = new ChoiceQuestion('Which environment? ', array_keys($app['environments']), null);
         $environment_name = $helper->ask($input, $output, $question);
     }
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     $environment = $app['environments'][$environment_name];
     $environment_factory = new EnvironmentFactory($environment, $app);
     $environment_factory->writeConfig();
     $current_scale = $environment_factory->getScale();
     $output->writeln("Scaling Environment <comment>{$app_name} {$environment_name}</comment>...");
     $output->writeln("Current scale: <comment>{$current_scale}</comment>");
     // If no scale ask for scale.
     if (empty($scale)) {
         $question = new Question('How many app containers? ');
         $scale = $helper->ask($input, $output, $question);
     }
     $output->writeln("Target scale: <comment>{$scale}</comment>");
     $environment_factory->scale($scale);
     $output->writeln("Environment <comment>{$app_name} {$environment_name}</comment> scaled to <info>{$scale}</info>");
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output->writeln("Hello Terra!");
     // If there are no apps, return
     if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) {
         $output->writeln("<comment>There are no apps!</comment>");
         $output->writeln("Use the command <info>terra app:add</info> to add your first app.");
         return;
     }
     $helper = $this->getHelper('question');
     $app_name = $input->getArgument('app_name');
     $environment_name = $input->getArgument('environment_name');
     // If no name specified provide options
     if (empty($app_name)) {
         $question = new ChoiceQuestion('Which app? ', array_keys($this->getApplication()->getTerra()->getConfig()->get('apps')), NULL);
         $app_name = $helper->ask($input, $output, $question);
     }
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     // If no environments:
     if (count($app['environments']) == 0) {
         $output->writeln("<comment>There are no environments!</comment>");
         $output->writeln("Use the command <info>terra environment:add</info> to add your first environment.");
         return;
     }
     // If no environment name specified provide options
     if (empty($environment_name)) {
         $question = new ChoiceQuestion('Which environment? ', array_keys($app['environments']), NULL);
         $environment_name = $helper->ask($input, $output, $question);
     }
     $environment = $app['environments'][$environment_name];
     $environment_factory = new EnvironmentFactory($environment, $app);
     $environment['scale'] = $environment_factory->getScale();
     $environment['url'] .= PHP_EOL . 'http://' . $environment_factory->getUrl();
     $table = $this->getHelper('table');
     $table->setHeaders(array('Name', 'Code Path', 'URL', 'Version', 'Scale'));
     $rows = array($environment);
     $table->setRows($rows);
     $table->render($output);
     $output->writeln("Docker Compose Path: " . $environment_factory->getDockerComposePath());
 }
Example #4
0
 /**
  * Outputs the status of an environment.
  *
  * @param \Symfony\Component\Console\Input\InputInterface   $input
  * @param \Symfony\Component\Console\Output\OutputInterface $output
  * @param $app
  * @param $environment
  *
  */
 protected function environmentStatus(InputInterface $input, OutputInterface $output)
 {
     // If there are no apps, return
     if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) {
         $output->writeln('<comment>There are no apps!</comment>');
         $output->writeln('Use the command <info>terra app:add</info> to add your first app.');
         return;
     }
     $app_name = $input->getArgument('app_name');
     $environment_name = $input->getArgument('environment_name');
     $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name);
     // If no environments:
     if (count($app['environments']) == 0) {
         $output->writeln('<comment>There are no environments!</comment>');
         $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.');
         return;
     }
     // If no environment by that name...
     if (!isset($app['environments'][$environment_name])) {
         $output->writeln("<error>There is no environment named {$environment_name} in the app {$app_name}</error>");
         return;
     }
     $environment = $app['environments'][$environment_name];
     $environment_factory = new EnvironmentFactory($environment, $app);
     $environment['scale'] = $environment_factory->getScale();
     $environment['url'] = 'http://' . $environment_factory->getHost() . ':' . $environment_factory->getPort();
     $environment['url'] .= PHP_EOL . 'http://' . $environment_factory->getUrl();
     $table = $this->getHelper('table');
     $table->setHeaders(array('Name', 'Code Path', 'docroot', 'URLs', 'Version', 'Scale'));
     $rows = array($environment);
     $table->setRows($rows);
     $table->render($output);
     $output->writeln('Docker Compose Path: ' . $environment_factory->getDockerComposePath());
 }