Beispiel #1
0
 /**
  * Displays an environment's regular backup schedule
  *
  * @params array $assoc_args Parameters and flags from the command line
  * @return void
  */
 private function showBackupSchedule($assoc_args)
 {
     $site = $this->sites->get(Input::siteName(array('args' => $assoc_args)));
     $env = $site->environments->get(Input::env(array('args' => $assoc_args, 'choices' => array('dev', 'live'))));
     $schedule = $env->backups->getBackupSchedule();
     if (is_null($schedule['daily_backup_hour'])) {
         $this->log()->info('Backups are not currently scheduled to be run.');
     } else {
         $this->output()->outputRecord($schedule);
     }
 }
Beispiel #2
0
 /**
  * Streams new and finished workflows to the console
  *
  * ## OPTIONS
  * [--site=<site>]
  * : Site from which to list workflows
  *
  * @subcommand watch
  */
 public function watch($args, $assoc_args)
 {
     $site = $this->sites->get(Input::siteName(array('args' => $assoc_args)));
     // Keep track of workflows that have been printed.
     // This is necessary because the local clock may drift from
     // the server's clock, causing events to be printed twice.
     $started = array();
     $finished = array();
     $this->logger->info('Watching workflows...');
     $site->workflows->fetchWithOperations();
     while (true) {
         $last_created_at = $site->workflows->lastCreatedAt();
         $last_finished_at = $site->workflows->lastFinishedAt();
         sleep(WORKFLOWS_WATCH_INTERVAL);
         $site->workflows->fetchWithOperations();
         $workflows = $site->workflows->all();
         foreach ($workflows as $workflow) {
             if ($workflow->get('created_at') > $last_created_at && !in_array($workflow->id, $started)) {
                 array_push($started, $workflow->id);
                 $started_message = sprintf("Started %s %s (%s)", $workflow->id, $workflow->get('description'), $workflow->get('environment'));
                 $this->logger->info($started_message);
             }
             if ($workflow->get('finished_at') > $last_finished_at && !in_array($workflow->id, $finished)) {
                 array_push($finished, $workflow->id);
                 $finished_message = sprintf("Finished Workflow %s %s (%s)", $workflow->id, $workflow->get('description'), $workflow->get('environment'));
                 $this->logger->info($finished_message);
                 if ($workflow->get('has_operation_log_output')) {
                     $workflow->fetchWithLogs();
                     $operations = $workflow->operations();
                     foreach ($operations as $operation) {
                         if ($operation->has('log_output')) {
                             $log_msg = sprintf("\n------ %s (%s) ------\n%s", $operation->description(), $operation->get('environment'), $operation->get('log_output'));
                             $this->log()->info($log_msg);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Parent function to SSH-based command invocations
  *
  * @param string[] $args       Command(s) given in the command line
  * @param string[] $assoc_args Arguments and flags passed into the former
  * @return array Elements as follow:
  *         Site   site    Site being invoked
  *         string env_id  Name of the environment being invoked
  *         string command Command to run remotely
  *         string server  Server connection info
  */
 protected function getElements($args, $assoc_args)
 {
     $this->ensureQuotation($args, $assoc_args);
     $command = array_pop($args);
     $this->checkCommand($command);
     $sites = new Sites();
     $site = $sites->get(Input::siteName(array('args' => $assoc_args)));
     if (!$site) {
         $this->failure('Command could not be completed. Unknown site specified.');
     }
     $env_id = Input::env(array('args' => $assoc_args, 'site' => $site));
     if (!in_array($env_id, ['test', 'live'])) {
         $this->checkConnectionMode($site->environments->get($env_id));
     }
     $elements = array('site' => $site, 'env_id' => $env_id, 'command' => $command, 'server' => $this->getAppserverInfo(array('site' => $site->get('id'), 'environment' => $env_id)));
     return $elements;
 }