harbr 0.0.67 → 0.0.69
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/exe/harbr +3 -2
- data/lib/harbr/next/job.rb +123 -0
- data/lib/harbr/version.rb +1 -1
- data/lib/harbr.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1848f4996f4de495baab3cb495d5322268fa2b241a6b730398a3eccdfdcbb14e
|
4
|
+
data.tar.gz: fbea4944a710247e6bfbda103954b362fa5e263916cd59bed9f78e1f0b7d743d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ab00982214a62f82d3d7d718aec943db7b5c5056f0ee76f14c8b7c5abc51818492a83bf135b2017044591cf92e6f13984ca20c7250effbd67b309e52dbfafcc
|
7
|
+
data.tar.gz: 971444bd9f9f62e2f370a2df122c800df01841182780a55d8e44cc73f4203fffb7c25c1777296fac1bcbc8b65631dab3a56df0091e2811a30c7b3f4dd812534f
|
data/exe/harbr
CHANGED
@@ -69,14 +69,15 @@ class HarbrCLI < Thor
|
|
69
69
|
|
70
70
|
def run_tasks(container, version)
|
71
71
|
puts "Running tasks for container: #{container}, version: #{version}"
|
72
|
-
puts "waiting for
|
72
|
+
puts "waiting for 3 seconds"
|
73
73
|
sleep 3
|
74
74
|
puts "done waiting"
|
75
75
|
if version.to_i == 0
|
76
76
|
puts "Initial Deploy!!! of #{container}"
|
77
77
|
Harbr::Job.perform_async(container, version)
|
78
78
|
else
|
79
|
-
|
79
|
+
Harbr::Next::Job.perform_async(container, version)
|
80
|
+
puts "deploy next version #{version} of #{container}"
|
80
81
|
|
81
82
|
end
|
82
83
|
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
module Harbr
|
2
|
+
module Next
|
3
|
+
class Job
|
4
|
+
include SuckerPunch::Job
|
5
|
+
|
6
|
+
def load_manifest(container,version)
|
7
|
+
manifest_path = "/var/harbr/#{container}/versions/#{version}/config/manifest.yml"
|
8
|
+
raise "Manifest not found at #{manifest_path}" unless File.exist?(manifest_path)
|
9
|
+
manifest_data = YAML.load_file(manifest_path)
|
10
|
+
OpenStruct.new(manifest_data)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_traefik_config(containers)
|
14
|
+
config = {
|
15
|
+
"http" => {
|
16
|
+
"routers" => {
|
17
|
+
"traefik-dashboard" => {
|
18
|
+
"rule" => "Host(`traefik.harbr.zero2one.ee`)",
|
19
|
+
"service" => "api@internal"
|
20
|
+
}
|
21
|
+
},
|
22
|
+
"services" => {}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
containers.each do |container|
|
27
|
+
container.ip = "127.0.0.1"
|
28
|
+
|
29
|
+
config["http"]["routers"]["#{container.name}-router"] = {
|
30
|
+
"rule" => "Host(`#{container.host_header}`)",
|
31
|
+
"service" => "#{container.name}-service"
|
32
|
+
}
|
33
|
+
config["http"]["services"]["#{container.name}-service"] = {
|
34
|
+
"loadBalancer" => {
|
35
|
+
"servers" => [{"url" => "http://#{container.ip}:#{container.port}"}]
|
36
|
+
}
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
File.write("/etc/traefik/harbr.toml", TomlRB.dump(config))
|
41
|
+
puts "Traefik configuration written to /etc/traefik/harbr.toml"
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_run_script(container_name, port)
|
45
|
+
|
46
|
+
service_dir = "/etc/sv/harbr/#{container_name}/next"
|
47
|
+
|
48
|
+
script_template = <<~SCRIPT
|
49
|
+
#!/bin/sh
|
50
|
+
exec 2>&1
|
51
|
+
cd /var/harbr/#{container_name}/next
|
52
|
+
exec ./exe/run #{port}
|
53
|
+
SCRIPT
|
54
|
+
|
55
|
+
service_dir = "/etc/sv/harbr/#{container_name}/next"
|
56
|
+
FileUtils.mkdir_p(service_dir)
|
57
|
+
|
58
|
+
File.write("#{service_dir}/run", script_template)
|
59
|
+
FileUtils.chmod("+x", "#{service_dir}/run")
|
60
|
+
puts "Run script created and made executable for container: next.#{container_name}"
|
61
|
+
end
|
62
|
+
|
63
|
+
def create_log_script(container_name)
|
64
|
+
log_dir = "/var/log/harbr/#{container_name}/next"
|
65
|
+
|
66
|
+
FileUtils.mkdir_p(log_dir)
|
67
|
+
|
68
|
+
script_template = <<~SCRIPT
|
69
|
+
#!/bin/sh
|
70
|
+
exec svlogd -tt #{log_dir}/
|
71
|
+
SCRIPT
|
72
|
+
|
73
|
+
dir_path = "/etc/sv/harbr/#{container_name}/next/log"
|
74
|
+
FileUtils.mkdir_p(dir_path)
|
75
|
+
|
76
|
+
File.write("#{dir_path}/run", script_template)
|
77
|
+
FileUtils.chmod("+x", "#{dir_path}/run")
|
78
|
+
puts "Log script created and made executable for container: next.#{container_name}"
|
79
|
+
end
|
80
|
+
|
81
|
+
def create_a_service(container_name, port)
|
82
|
+
create_run_script(container_name, port)
|
83
|
+
create_log_script(container_name)
|
84
|
+
system("ln -s /etc/sv/harbr/#{container_name}/next /etc/service/next.#{container_name}") unless File.exist?("/etc/service/next.#{container_name}")
|
85
|
+
end
|
86
|
+
|
87
|
+
def run_container(manifest)
|
88
|
+
puts "Starting container: next.#{manifest.name}"
|
89
|
+
port = `port assign next.#{manifest.port}`.strip
|
90
|
+
|
91
|
+
create_a_service(manifest.name, port)
|
92
|
+
|
93
|
+
containers = Container::Repository.new
|
94
|
+
container = containers.find_by_header("next.#{manifest.host}")
|
95
|
+
|
96
|
+
if container.nil?
|
97
|
+
container = Container.new
|
98
|
+
container.name = "next.#{manifest.name}"
|
99
|
+
container.host_header = "next.#{manifest.host}"
|
100
|
+
container.ip = "127.0.0.1"
|
101
|
+
container.port = port
|
102
|
+
containers.create(container)
|
103
|
+
else
|
104
|
+
container.port = port
|
105
|
+
containers.update(container)
|
106
|
+
end
|
107
|
+
|
108
|
+
system("cd /var/harbr/#{manifest.name}/next && bundle install")
|
109
|
+
system("sv restart next.#{manifest.name}")
|
110
|
+
puts "Started container: next.#{manifest.name}"
|
111
|
+
create_traefik_config(containers.all)
|
112
|
+
end
|
113
|
+
|
114
|
+
def perform(container, version)
|
115
|
+
puts "Running tasks for container: 'next.#{container}', Version: '#{version}'"
|
116
|
+
manifest = load_manifest(container, version)
|
117
|
+
puts "Manifest: #{manifest}"
|
118
|
+
system("ln -sf /var/harbr/#{container}/versions/#{version} /var/harbr/#{container}/next")
|
119
|
+
run_container(manifest)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
data/lib/harbr/version.rb
CHANGED
data/lib/harbr.rb
CHANGED
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.
|
4
|
+
version: 0.0.69
|
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-
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|
@@ -134,6 +134,7 @@ files:
|
|
134
134
|
- lib/harbr.rb
|
135
135
|
- lib/harbr/container.rb
|
136
136
|
- lib/harbr/job.rb
|
137
|
+
- lib/harbr/next/job.rb
|
137
138
|
- lib/harbr/version.rb
|
138
139
|
- sig/harbr.rbs
|
139
140
|
homepage: https://github.com/delaneyburke/harbr
|