harbr 0.0.69 → 0.0.70

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1848f4996f4de495baab3cb495d5322268fa2b241a6b730398a3eccdfdcbb14e
4
- data.tar.gz: fbea4944a710247e6bfbda103954b362fa5e263916cd59bed9f78e1f0b7d743d
3
+ metadata.gz: 0e797dfe98b5f3f8b54dfd54f4300b98893c12d688aa799003cffc5616f59597
4
+ data.tar.gz: 3ba62188cf4275cfd2ee7d536bde3523ac3661df04bf25fa00f9f9df1e3ffb42
5
5
  SHA512:
6
- metadata.gz: 9ab00982214a62f82d3d7d718aec943db7b5c5056f0ee76f14c8b7c5abc51818492a83bf135b2017044591cf92e6f13984ca20c7250effbd67b309e52dbfafcc
7
- data.tar.gz: 971444bd9f9f62e2f370a2df122c800df01841182780a55d8e44cc73f4203fffb7c25c1777296fac1bcbc8b65631dab3a56df0091e2811a30c7b3f4dd812534f
6
+ metadata.gz: f84b37919dfbffb691e8823454457c40a2acd2d00710350632960e30462203f9638c5ab8b5b323ce08e373cadd3786b0409d87f717e1949317a651ea6f35c44a
7
+ data.tar.gz: edf02e829ba5bc62604ac3cd2fdbc7f3584f7a4305283426b2ae262d51be737263558d7e525c4949de37d1583d7a0a08ff77f7fd0fddc0730d62c74cced5469d
data/lib/harbr/job.rb CHANGED
@@ -106,6 +106,7 @@ module Harbr
106
106
  end
107
107
 
108
108
  system("cd /var/harbr/#{manifest.name}/current && bundle install")
109
+ puts `lsof -i :#{port} | awk 'NR!=1 {print $2}' | xargs kill -9`
109
110
  system("sv restart #{manifest.name}")
110
111
  puts "Started container: #{manifest.name}"
111
112
  create_traefik_config(containers.all)
@@ -2,14 +2,14 @@ module Harbr
2
2
  module Next
3
3
  class Job
4
4
  include SuckerPunch::Job
5
-
6
- def load_manifest(container,version)
5
+
6
+ def load_manifest(container, version)
7
7
  manifest_path = "/var/harbr/#{container}/versions/#{version}/config/manifest.yml"
8
8
  raise "Manifest not found at #{manifest_path}" unless File.exist?(manifest_path)
9
9
  manifest_data = YAML.load_file(manifest_path)
10
10
  OpenStruct.new(manifest_data)
11
11
  end
12
-
12
+
13
13
  def create_traefik_config(containers)
14
14
  config = {
15
15
  "http" => {
@@ -22,10 +22,10 @@ module Harbr
22
22
  "services" => {}
23
23
  }
24
24
  }
25
-
25
+
26
26
  containers.each do |container|
27
27
  container.ip = "127.0.0.1"
28
-
28
+
29
29
  config["http"]["routers"]["#{container.name}-router"] = {
30
30
  "rule" => "Host(`#{container.host_header}`)",
31
31
  "service" => "#{container.name}-service"
@@ -36,86 +36,92 @@ module Harbr
36
36
  }
37
37
  }
38
38
  end
39
-
39
+
40
40
  File.write("/etc/traefik/harbr.toml", TomlRB.dump(config))
41
41
  puts "Traefik configuration written to /etc/traefik/harbr.toml"
42
42
  end
43
-
44
- def create_run_script(container_name, port)
45
43
 
44
+ def create_run_script(container_name, port)
46
45
  service_dir = "/etc/sv/harbr/#{container_name}/next"
47
-
46
+
48
47
  script_template = <<~SCRIPT
49
48
  #!/bin/sh
50
49
  exec 2>&1
51
50
  cd /var/harbr/#{container_name}/next
52
51
  exec ./exe/run #{port}
53
52
  SCRIPT
54
-
53
+
55
54
  service_dir = "/etc/sv/harbr/#{container_name}/next"
56
55
  FileUtils.mkdir_p(service_dir)
57
-
56
+
58
57
  File.write("#{service_dir}/run", script_template)
59
58
  FileUtils.chmod("+x", "#{service_dir}/run")
60
59
  puts "Run script created and made executable for container: next.#{container_name}"
61
60
  end
62
-
61
+
63
62
  def create_log_script(container_name)
64
63
  log_dir = "/var/log/harbr/#{container_name}/next"
65
-
64
+
66
65
  FileUtils.mkdir_p(log_dir)
67
-
66
+
68
67
  script_template = <<~SCRIPT
69
68
  #!/bin/sh
70
69
  exec svlogd -tt #{log_dir}/
71
70
  SCRIPT
72
-
71
+
73
72
  dir_path = "/etc/sv/harbr/#{container_name}/next/log"
74
73
  FileUtils.mkdir_p(dir_path)
75
-
74
+
76
75
  File.write("#{dir_path}/run", script_template)
77
76
  FileUtils.chmod("+x", "#{dir_path}/run")
78
77
  puts "Log script created and made executable for container: next.#{container_name}"
79
78
  end
80
-
79
+
81
80
  def create_a_service(container_name, port)
82
81
  create_run_script(container_name, port)
83
82
  create_log_script(container_name)
83
+
84
84
  system("ln -s /etc/sv/harbr/#{container_name}/next /etc/service/next.#{container_name}") unless File.exist?("/etc/service/next.#{container_name}")
85
85
  end
86
-
86
+
87
87
  def run_container(manifest)
88
88
  puts "Starting container: next.#{manifest.name}"
89
- port = `port assign next.#{manifest.port}`.strip
89
+ port = system("port assign next.#{manifest.port}").strip
90
+ puts "Port assigned: #{port}"
90
91
 
91
92
  create_a_service(manifest.name, port)
92
-
93
+
93
94
  containers = Container::Repository.new
94
95
  container = containers.find_by_header("next.#{manifest.host}")
95
-
96
+
96
97
  if container.nil?
97
- container = Container.new
98
+ container = Container.new
98
99
  container.name = "next.#{manifest.name}"
99
100
  container.host_header = "next.#{manifest.host}"
100
101
  container.ip = "127.0.0.1"
101
102
  container.port = port
102
103
  containers.create(container)
103
104
  else
104
- container.port = port
105
- containers.update(container)
105
+ container.port = port
106
+ containers.update(container)
106
107
  end
107
-
108
+
109
+
110
+
108
111
  system("cd /var/harbr/#{manifest.name}/next && bundle install")
112
+
113
+
114
+ puts `lsof -i :#{port} | awk 'NR!=1 {print $2}' | xargs kill -9`
109
115
  system("sv restart next.#{manifest.name}")
116
+
110
117
  puts "Started container: next.#{manifest.name}"
111
118
  create_traefik_config(containers.all)
112
119
  end
113
-
120
+
114
121
  def perform(container, version)
115
122
  puts "Running tasks for container: 'next.#{container}', Version: '#{version}'"
116
123
  manifest = load_manifest(container, version)
117
124
  puts "Manifest: #{manifest}"
118
- system("ln -sf /var/harbr/#{container}/versions/#{version} /var/harbr/#{container}/next")
119
125
  run_container(manifest)
120
126
  end
121
127
  end
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.69"
4
+ VERSION = "0.0.70"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harbr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.69
4
+ version: 0.0.70
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke