Class: Jatai::Commands::Run

Inherits:
Base
  • Object
show all
Defined in:
lib/jatai/commands/run.rb

Overview

jatai run "" — executa um comando one-off num pod efêmero com a imagem do release atual, streama a saída e retorna o exit code real.

Constant Summary collapse

RUN_TIMEOUT =

activeDeadlineSeconds (900) + folga

960

Instance Method Summary collapse

Methods inherited from Base

#api, #app_name, #app_slug, #error, #info, #pastel, #project_config, #require_auth!, #success

Instance Method Details

#execute(command_parts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/jatai/commands/run.rb', line 10

def execute(command_parts)
  require_auth!
  command = Array(command_parts).join(" ").strip
  return error("Informe o comando: jatai run \"bin/rails runner '...'\"") if command.empty?

  slug = app_slug
  run = api.post("/api/v1/apps/#{slug}/runs", body: { command: command })
  info("Run ##{run["id"]} criado — subindo pod efêmero com o release atual...")

  status = follow(run["id"])
  finish(slug, run["id"], status)
rescue Api::Client::ValidationError => e
  error("Erro: #{e.message}")
  exit(1)
rescue Api::Client::ApiError => e
  error("Erro: #{e.message}")
  exit(1)
end