Method: Command::Run#call

Defined in:
lib/command/run.rb

#callObject

rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/command/run.rb', line 102

def call # rubocop:disable Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
  @interactive = config.options[:interactive] || interactive_command?
  @detached = config.options[:detached]
  @log_method = config.options[:log_method]

  @location = config.location
  @original_workload = config.options[:workload] || config[:one_off_workload]
  @runner_workload = "#{original_workload}-runner"
  @default_image = "#{config.app}:#{Controlplane::NO_IMAGE_AVAILABLE}"
  @default_cpu = config.current[:runner_job_default_cpu] || DEFAULT_JOB_CPU
  @default_memory = config.current[:runner_job_default_memory] || DEFAULT_JOB_MEMORY
  @job_timeout = config.current[:runner_job_timeout] || DEFAULT_JOB_TIMEOUT
  @job_history_limit = DEFAULT_JOB_HISTORY_LIMIT

  unless interactive
    @internal_sigint = false

    # Catch Ctrl+C in the main process
    trap("SIGINT") do
      unless @internal_sigint
        print_detached_commands
        exit(ExitCode::INTERRUPT)
      end
    end
  end

  create_runner_workload if cp.fetch_workload(runner_workload).nil?
  wait_for_runner_workload_deploy
  update_runner_workload
  wait_for_runner_workload_update if expected_deployed_version

  start_job
  wait_for_replica_for_job

  progress.puts
  if interactive
    run_interactive
  else
    run_non_interactive
  end
end