harbr 0.0.107 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8e70f482635d3b1b64c52bb51739e14312704008cb68942552e2c67adcddb0e
4
- data.tar.gz: c558200bca48af358ce3a87847c5a156b626ab34a03605ee4d49ffeeaeba5d5b
3
+ metadata.gz: f9c8544c1daf62daab459ca9f4d2953b5ad688b8856571326cea06fd486272b6
4
+ data.tar.gz: 2979d7301cd49b3477f38ab0293e37045027cb1d469731378132c2dc4cc59b3c
5
5
  SHA512:
6
- metadata.gz: 43b3bc4c2e5af49eca364bca97f5a13afb88047aa022e023d8679aba4532eebffb4070a07d9fae4741f0bc38eeeb7c56fb372fd446cc21729e8e74a3394a974b
7
- data.tar.gz: a56babd7d75c1c9a2c1840747d064cc3c0efe5a38862fd584d6270d675d4d80ed547ecfd3cf00a00a62f3c476ef2d0c583320347db5583883efd01207fbf88c2
6
+ metadata.gz: ceaf8c984d22e2e7e8faf87519601eefbafc8a598caae1e817ce6db6900bc12e2e0b2f20138459f78eaec423eb0f587ba828cbef292586b9ab4835070e2bcbad
7
+ data.tar.gz: 469ccc69aa021a4f141596dad901c2af9f386f44b2c9724843c5cb79690b1301065b9ac015c34873445d4afdb6f1e4011f96625b6c0f94feef93ad90e9977800
data/exe/harbr CHANGED
@@ -7,10 +7,10 @@ class HarbrCLI < Thor
7
7
  return puts "No containers available." if containers.empty?
8
8
 
9
9
  # Define headers based on Container attributes
10
- headers = ["Name", "Host Header", "IP", "Port", "Current Version", "Next Version", "Previous Version"]
10
+ headers = ["Name", "Host Header", "IP", "Port"]
11
11
 
12
12
  rows = containers.map do |container|
13
- [container.name, container.host_header, container.ip.nil? ? "127.0.0.1" : container.ip, container.port.to_s, container.current_version, container.next_version, container.previous_version]
13
+ [container.name, container.host_header, container.ip.nil? ? "127.0.0.1" : container.ip, container.port]
14
14
  end
15
15
 
16
16
  table = ::Terminal::Table.new(headings: headers, rows: rows)
@@ -172,20 +172,22 @@ class HarbrCLI < Thor
172
172
  desc "deploy", "deploy a container to production"
173
173
  def deploy(name)
174
174
  Dir.chdir("/var/harbr/containers/#{name}/") do
175
- `mv current rollback`
176
175
  `mv next current`
177
- puts `sv restart #{name}`
176
+ puts `sv restart next.#{name}`
178
177
  end
179
-
180
178
  end
181
179
 
182
180
  desc "rollback", "rollback last deploy"
183
181
  def rollback(name)
184
182
  Dir.chdir("/var/harbr/containers/#{name}") do
185
183
  if File.exist?("rollback")
186
- `sv stop #{name}`
184
+ `cp -r current current.bak`
187
185
  `mv rollback current`
188
- `sv start #{name}`
186
+ `cp -r current.bak next`
187
+ `rm -rf rollback`
188
+ `rm -rf current.bak`
189
+ `sv restart #{name}`
190
+ `sv restart next.#{name}`
189
191
  puts "rollback successful"
190
192
  end
191
193
  end
@@ -210,5 +212,4 @@ class HarbrCLI < Thor
210
212
  end
211
213
  end
212
214
  end
213
-
214
215
  HarbrCLI.start(ARGV)
@@ -1,7 +1,7 @@
1
1
  module Harbr
2
2
  class Container
3
3
  include Dddr::Entity
4
- attr_accessor :name, :host_header, :ip, :port,:current_version, :next_version,:previous_version
4
+ attr_accessor :name, :host_header, :ip, :port
5
5
 
6
6
  queries do
7
7
  def find_by_header(host_header)
data/lib/harbr/job.rb CHANGED
@@ -56,7 +56,6 @@ module Harbr
56
56
  container.host_header =host
57
57
  container.ip = "127.0.0.1"
58
58
  container.port = port
59
- container.current_version = 0
60
59
  containers.create(container)
61
60
  else
62
61
  container.port = port
@@ -50,16 +50,22 @@ module Harbr
50
50
  puts "Traefik configuration written to /etc/traefik/harbr.toml"
51
51
  end
52
52
 
53
- def collate_containers(name,port, version)
53
+ def collate_containers(name,host,port)
54
54
 
55
55
  containers = Harbr::Container::Repository.new
56
- container = containers.find_by_name(name)
56
+ container = containers.find_by_header(host)
57
57
 
58
- container.port = port
59
- container.next_version = version
60
- container.previous_version = container.current_version
61
- containers.update(container)
62
-
58
+ if container.nil?
59
+ container = Harbr::Container.new
60
+ container.name = name
61
+ container.host_header =host
62
+ container.ip = "127.0.0.1"
63
+ container.port = port
64
+ containers.create(container)
65
+ else
66
+ container.port = port
67
+ containers.update(container)
68
+ end
63
69
  containers.all
64
70
  end
65
71
 
@@ -166,8 +172,7 @@ module Harbr
166
172
  `bundle config set --local path 'vendor/bundle'`
167
173
 
168
174
  manifest = load_manifest(name,version)
169
-
170
- current_path = "/var/harbr/containers/#{name}/current"
175
+ current_path = "/var/harbr/containers/#{name}/versions/#{version}"
171
176
 
172
177
  port = `port assign next.#{manifest.port}`.strip
173
178
 
@@ -190,12 +195,13 @@ module Harbr
190
195
 
191
196
 
192
197
  system "rm /etc/service/next.#{name}"
198
+ system "rm /var/harbr/containers/#{name}/next"
193
199
 
194
200
  system "ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next"
195
201
  system "ln -sf /etc/sv/harbr/#{name}/next /etc/service/next.#{name}"
196
202
  system "sv restart next.#{name}"
197
203
 
198
- containers = collate_containers("next.#{name}",port,version)
204
+ containers = collate_containers("next.#{name}","next.#{manifest.host}",port)
199
205
  create_traefik_config(containers)
200
206
  end
201
207
 
data/lib/harbr/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Harbr
4
- VERSION = "0.0.107"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.107
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2023-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: listen