brasa 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/brasa/cli.rb +2 -2
- data/lib/brasa/commands/database.rb +1 -3
- data/lib/brasa/commands/init.rb +10 -8
- data/lib/brasa/commands/logs.rb +5 -5
- data/lib/brasa/commands/logs_export.rb +1 -1
- data/lib/brasa/commands/scale.rb +5 -2
- data/lib/brasa/commands/status.rb +5 -2
- data/lib/brasa/commands/up.rb +4 -4
- data/lib/brasa/version.rb +1 -1
- data/lib/brasa/websocket/cable_client.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c43a2e611cb76f921a9c2066be2fe84a4da611eb81aff758d47bb481a09f3710
|
|
4
|
+
data.tar.gz: 78108a8be50018a5ff96ad2c4026e20b2942d74234d335e0aad065360976ef00
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7cf9cf1b338037c816efadd34cc79a395b0d24a6edb045d9d3cce197a678274b8ddafcc7a925c35480fd2b37ed579fba5014c8da5525bad67bfadc0ddeeda4d3
|
|
7
|
+
data.tar.gz: 8766f38b9203e02dd9f92f8fa0c21fd4c94c4ace3362c1b9c28925cfcd36833873665ffb4d80e0621f42b1f24cf546eef787e12b2b24be2b9aa402c3b6cad78e
|
data/lib/brasa/cli.rb
CHANGED
|
@@ -79,8 +79,8 @@ module Brasa
|
|
|
79
79
|
subcommand "redis", Commands::Redis
|
|
80
80
|
|
|
81
81
|
desc "scale", "Escalar a aplicação"
|
|
82
|
-
option :
|
|
83
|
-
option :preset, type: :string, desc: "Preset (
|
|
82
|
+
option :replicas, type: :numeric, desc: "Número de réplicas"
|
|
83
|
+
option :preset, type: :string, desc: "Preset (micro, hobby, pro)"
|
|
84
84
|
def scale
|
|
85
85
|
Commands::Scale.new.execute(options)
|
|
86
86
|
end
|
|
@@ -14,13 +14,11 @@ module Brasa
|
|
|
14
14
|
db = helper.api.get("/api/v1/apps/#{slug}/database")
|
|
15
15
|
|
|
16
16
|
puts helper.pastel.bold("Banco de dados de #{slug}")
|
|
17
|
-
puts "
|
|
18
|
-
puts " Modo: #{db["mode"]}"
|
|
17
|
+
puts " Tier: #{db["database_tier"] || db["mode"]}"
|
|
19
18
|
puts " Host: #{db["host"]}"
|
|
20
19
|
puts " Porta: #{db["port"]}"
|
|
21
20
|
puts " Nome: #{db["name"]}"
|
|
22
21
|
puts " Status: #{db["status"]}"
|
|
23
|
-
puts " Machine: #{db["machine_type"]}" if db["machine_type"] && db["machine_type"] != "embedded"
|
|
24
22
|
rescue Api::Client::ApiError => e
|
|
25
23
|
helper.error("Erro: #{e.message}")
|
|
26
24
|
end
|
data/lib/brasa/commands/init.rb
CHANGED
|
@@ -6,16 +6,18 @@ module Brasa
|
|
|
6
6
|
module Commands
|
|
7
7
|
class Init < Base
|
|
8
8
|
PRESETS = {
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"production" => "Production — 2 vCPU, 4GB RAM, 40GB disco, DB managed + storage (R$ 299/mês)",
|
|
13
|
-
"scale" => "Scale — 4 vCPU, 8GB RAM, 100GB disco, DB managed + storage (R$ 599/mês)"
|
|
9
|
+
"micro" => "Micro — 256MB RAM, 1 réplica (Grátis)",
|
|
10
|
+
"hobby" => "Hobby — 1GB RAM, réplicas ilimitadas (R$ 19/mês)",
|
|
11
|
+
"pro" => "Pro — 2GB RAM, réplicas ilimitadas (R$ 69/mês)"
|
|
14
12
|
}.freeze
|
|
15
13
|
|
|
16
14
|
REGIONS = { "br-se1" => "São Paulo", "br-ne1" => "Nordeste" }.freeze
|
|
17
15
|
STACKS = { "rails" => "Rails", "node" => "Node.js", "docker" => "Docker (custom Dockerfile)" }.freeze
|
|
18
|
-
|
|
16
|
+
DATABASE_TIERS = {
|
|
17
|
+
"mini" => "Mini — 512MB, 20 conexões (Grátis)",
|
|
18
|
+
"essencial" => "Essencial — 1GB, 50 conexões (R$ 19/mês)",
|
|
19
|
+
"padrao" => "Padrão — 5GB, 100 conexões (R$ 49/mês)"
|
|
20
|
+
}.freeze
|
|
19
21
|
|
|
20
22
|
def execute(options = {})
|
|
21
23
|
prompt = TTY::Prompt.new
|
|
@@ -39,7 +41,7 @@ module Brasa
|
|
|
39
41
|
name = prompt.ask("Nome do app:") { |q| q.required true }
|
|
40
42
|
preset = prompt.select("Preset:", PRESETS.map { |k, v| { name: v, value: k } })
|
|
41
43
|
region = prompt.select("Região:", REGIONS.map { |k, v| { name: "#{v} (#{k})", value: k } })
|
|
42
|
-
|
|
44
|
+
db_tier = prompt.select("Banco de dados:", DATABASE_TIERS.map { |k, v| { name: v, value: k } })
|
|
43
45
|
branch = detect_git_branch || "main"
|
|
44
46
|
|
|
45
47
|
config = {
|
|
@@ -48,7 +50,7 @@ module Brasa
|
|
|
48
50
|
"preset" => preset,
|
|
49
51
|
"region" => region,
|
|
50
52
|
"branch" => branch,
|
|
51
|
-
"
|
|
53
|
+
"database_tier" => db_tier
|
|
52
54
|
}
|
|
53
55
|
|
|
54
56
|
File.write(config_path, YAML.dump(config))
|
data/lib/brasa/commands/logs.rb
CHANGED
|
@@ -24,11 +24,11 @@ module Brasa
|
|
|
24
24
|
message = entry["message"]
|
|
25
25
|
|
|
26
26
|
level_str = case level
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
when "error" then pastel.red(level)
|
|
28
|
+
when "warn" then pastel.yellow(level)
|
|
29
|
+
when "info" then pastel.green(level)
|
|
30
|
+
else pastel.dim(level || "log")
|
|
31
|
+
end
|
|
32
32
|
|
|
33
33
|
puts "#{pastel.dim(timestamp)} #{pastel.cyan(source)} [#{level_str}] #{message}"
|
|
34
34
|
end
|
data/lib/brasa/commands/scale.rb
CHANGED
|
@@ -9,15 +9,18 @@ module Brasa
|
|
|
9
9
|
slug = app_slug
|
|
10
10
|
|
|
11
11
|
body = {}
|
|
12
|
-
body[:
|
|
12
|
+
body[:replicas] = options["replicas"].to_i if options["replicas"]
|
|
13
13
|
body[:preset] = options["preset"] if options["preset"]
|
|
14
14
|
|
|
15
15
|
if body.empty?
|
|
16
|
-
error("Informe ao menos --
|
|
16
|
+
error("Informe ao menos --replicas ou --preset. Ex: brasa scale --replicas 3")
|
|
17
17
|
return
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
estimate = api.post("/api/v1/apps/#{slug}/scale/estimate", body: body)
|
|
21
|
+
info("Preset: #{estimate["preset"]}")
|
|
22
|
+
info("Réplicas: #{estimate["replicas"]}") if estimate["replicas"]
|
|
23
|
+
info("CPU: #{estimate["cpu_limit"]} | RAM: #{estimate["memory_limit"]}") if estimate["cpu_limit"]
|
|
21
24
|
info("Custo estimado: R$ #{estimate["monthly_cost"]}/mês")
|
|
22
25
|
|
|
23
26
|
prompt = TTY::Prompt.new
|
|
@@ -15,8 +15,9 @@ module Brasa
|
|
|
15
15
|
puts " Status: #{colorize_status(app["status"])}"
|
|
16
16
|
puts " Região: #{app["region"]}"
|
|
17
17
|
puts " Preset: #{app["preset"]}"
|
|
18
|
-
puts " DB: #{app["
|
|
19
|
-
|
|
18
|
+
puts " DB: #{app["database_tier"]}"
|
|
19
|
+
subdomain = app["subdomain"] || app["slug"]
|
|
20
|
+
puts " URL: https://#{subdomain}.usebrasa.com.br"
|
|
20
21
|
|
|
21
22
|
if app["last_deploy"]
|
|
22
23
|
deploy = app["last_deploy"]
|
|
@@ -37,6 +38,8 @@ module Brasa
|
|
|
37
38
|
case status
|
|
38
39
|
when "active", "live"
|
|
39
40
|
pastel.green(status)
|
|
41
|
+
when "sleeping"
|
|
42
|
+
pastel.blue(status)
|
|
40
43
|
when "failed", "error"
|
|
41
44
|
pastel.red(status)
|
|
42
45
|
when "building", "deploying", "provisioning"
|
data/lib/brasa/commands/up.rb
CHANGED
|
@@ -18,7 +18,7 @@ module Brasa
|
|
|
18
18
|
@app = find_or_create_app(config)
|
|
19
19
|
slug = @app["slug"]
|
|
20
20
|
|
|
21
|
-
if @app["status"]
|
|
21
|
+
if %w[active sleeping].include?(@app["status"])
|
|
22
22
|
info("Iniciando deploy...")
|
|
23
23
|
else
|
|
24
24
|
info("Provisionando infraestrutura...")
|
|
@@ -72,7 +72,7 @@ module Brasa
|
|
|
72
72
|
name: config[:app], stack: config[:stack], preset: config[:preset],
|
|
73
73
|
region: config[:region], repo_url: detect_git_remote, repo_branch: config[:branch]
|
|
74
74
|
}
|
|
75
|
-
app_params[:
|
|
75
|
+
app_params[:database_tier] = config[:database_tier] if config[:database_tier]
|
|
76
76
|
api.post("/api/v1/apps", body: { app: app_params })
|
|
77
77
|
end
|
|
78
78
|
|
|
@@ -205,9 +205,9 @@ module Brasa
|
|
|
205
205
|
end
|
|
206
206
|
|
|
207
207
|
def status_label(status)
|
|
208
|
-
{ "pending" => "Aguardando...", "provisioning" => "Provisionando
|
|
208
|
+
{ "pending" => "Aguardando...", "provisioning" => "Provisionando...",
|
|
209
209
|
"queued" => "Na fila...", "building" => "Construindo imagem...",
|
|
210
|
-
"deploying" => "
|
|
210
|
+
"deploying" => "Implantando..." }[status] || status
|
|
211
211
|
end
|
|
212
212
|
|
|
213
213
|
def show_elapsed(started)
|
data/lib/brasa/version.rb
CHANGED