harbr 0.1.39 → 0.1.42
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/config/manifest.yml +1 -1
- data/exe/harbr +2 -2
- data/lib/harbr/job.rb +111 -84
- data/lib/harbr/version.rb +1 -1
- data/lib/harbr.rb +0 -1
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/ffi-1.16.3/ffi_c.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/ffi-1.16.3/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/json-2.7.0/gem_make.out +4 -4
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/json-2.7.0/json/ext/generator.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/json-2.7.0/json/ext/parser.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/racc-1.7.3/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/racc-1.7.3/racc/cparse.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/sdbm-1.0.0/gem_make.out +5 -5
- data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/sdbm-1.0.0/sdbm.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/lib/ffi_c.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/lib/json/ext/generator.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/lib/json/ext/parser.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/lib/racc/cparse.bundle +0 -0
- data/vendor/bundle/ruby/3.2.0/gems/sdbm-1.0.0/lib/sdbm.bundle +0 -0
- metadata +1 -2
- data/lib/harbr/next/job.rb +0 -211
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b4a81834b6e281138d670063f16e6ce3aef3ba2a4c611126c5769f7a800c6a43
|
|
4
|
+
data.tar.gz: '09c9cb7ba2a44b1d61282c05c63d5cf6a9ea96711d063805268b15fbee0b4569'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 11e9eb1bc37ab2095afcac4509521c414d38c7b40fbe0215d9e035d0bfda830999b9c210576cf8dea4903ad35e13bb8062eeb6c5eb2cdeb4f9a7b4fa6e4008c9
|
|
7
|
+
data.tar.gz: 1ecaed7982e06159ef3a16956754fc8d5c677c4ffa40548852a5685a36ab68971d22f317455fa27d01794118d14be762e6ea8caf832dbc73160e86f3ff81ca17
|
data/config/manifest.yml
CHANGED
data/exe/harbr
CHANGED
|
@@ -92,10 +92,10 @@ class HarbrCLI < Thor
|
|
|
92
92
|
Dir.exist?("/var/harbr/containers/#{container}/versions/#{version}/config/manifest.yml")
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
Harbr::Job.perform_async(container,
|
|
95
|
+
Harbr::Job.perform_async(container, versio,"live")
|
|
96
96
|
else
|
|
97
97
|
sleep 3
|
|
98
|
-
Harbr::
|
|
98
|
+
Harbr::Job.perform_async(container, version,"next")
|
|
99
99
|
puts "deploy next version #{version} of #{container}"
|
|
100
100
|
end
|
|
101
101
|
|
data/lib/harbr/job.rb
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
+
require "yaml"
|
|
2
|
+
require "ostruct"
|
|
3
|
+
require "sucker_punch"
|
|
1
4
|
require "harbr"
|
|
5
|
+
require "tomlrb"
|
|
6
|
+
|
|
2
7
|
module Harbr
|
|
3
8
|
class Job
|
|
4
9
|
include SuckerPunch::Job
|
|
@@ -10,13 +15,7 @@ module Harbr
|
|
|
10
15
|
def create_traefik_config(containers)
|
|
11
16
|
config = {
|
|
12
17
|
"http" => {
|
|
13
|
-
"routers" => {
|
|
14
|
-
"traefik-dashboard" => {
|
|
15
|
-
"rule" => "Host(`traefik.harbr.zero2one.ee`)",
|
|
16
|
-
"service" => "api@internal",
|
|
17
|
-
"tls" => {} # Enable TLS for the dashboard
|
|
18
|
-
}
|
|
19
|
-
},
|
|
18
|
+
"routers" => {},
|
|
20
19
|
"services" => {}
|
|
21
20
|
}
|
|
22
21
|
}
|
|
@@ -25,18 +24,16 @@ module Harbr
|
|
|
25
24
|
container.ip = "127.0.0.1"
|
|
26
25
|
name = container.name.tr(".", "-")
|
|
27
26
|
|
|
28
|
-
# Create the router with TLS enabled and specific format
|
|
29
27
|
router_key = "#{name}-router-secure"
|
|
30
28
|
config["http"]["routers"][router_key] = {
|
|
31
29
|
"rule" => "Host(`#{container.host_header}`)",
|
|
32
30
|
"service" => "#{name}-service",
|
|
33
31
|
"entryPoints" => ["https"],
|
|
34
32
|
"tls" => {
|
|
35
|
-
"certResolver" => "myresolver"
|
|
33
|
+
"certResolver" => "myresolver"
|
|
36
34
|
}
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
# Create the service
|
|
40
37
|
config["http"]["services"]["#{name}-service"] = {
|
|
41
38
|
"loadBalancer" => {
|
|
42
39
|
"servers" => [{"url" => "http://#{container.ip}:#{container.port}"}]
|
|
@@ -44,7 +41,6 @@ module Harbr
|
|
|
44
41
|
}
|
|
45
42
|
end
|
|
46
43
|
|
|
47
|
-
# Write the configuration to a TOML file
|
|
48
44
|
File.write("/etc/traefik/harbr.toml", TomlRB.dump(config))
|
|
49
45
|
puts "Traefik configuration written to /etc/traefik/harbr.toml"
|
|
50
46
|
end
|
|
@@ -64,99 +60,130 @@ module Harbr
|
|
|
64
60
|
container.port = port
|
|
65
61
|
containers.update(container)
|
|
66
62
|
end
|
|
63
|
+
|
|
67
64
|
containers.all
|
|
68
65
|
end
|
|
69
66
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@container_name = container
|
|
74
|
-
@port = port
|
|
75
|
-
end
|
|
67
|
+
def write_to_file(path, contents)
|
|
68
|
+
File.write(path, contents)
|
|
69
|
+
end
|
|
76
70
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
exec 2>&1
|
|
81
|
-
cd /var/harbr/containers/#{@container_name}/current
|
|
82
|
-
exec ./exe/run #{@port} live
|
|
83
|
-
SCRIPT
|
|
84
|
-
end
|
|
71
|
+
def load_manifest(container, version)
|
|
72
|
+
manifest_path = "/var/harbr/containers/#{container}/versions/#{version}/config/manifest.yml"
|
|
73
|
+
raise "Manifest not found at #{manifest_path}" unless File.exist?(manifest_path)
|
|
85
74
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
75
|
+
manifest_data = YAML.load_file(manifest_path)
|
|
76
|
+
OpenStruct.new(manifest_data)
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def perform(name, version, env)
|
|
80
|
+
Harbr.notifiable(name, version) do
|
|
81
|
+
manifest = load_manifest(name, version)
|
|
82
|
+
port = `port assign #{env}.#{manifest.port}`.strip
|
|
83
|
+
|
|
84
|
+
current_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
|
85
|
+
check_dir_exists(current_path)
|
|
86
|
+
|
|
87
|
+
process_container(name, version, port, env, manifest)
|
|
89
88
|
end
|
|
89
|
+
end
|
|
90
90
|
|
|
91
|
-
|
|
92
|
-
def initialize(port)
|
|
93
|
-
@port = port
|
|
94
|
-
end
|
|
91
|
+
private
|
|
95
92
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
93
|
+
def check_dir_exists(path)
|
|
94
|
+
sleep_times = [1, 3, 5, 8, 23]
|
|
95
|
+
begin
|
|
96
|
+
sleep_times.each do |time|
|
|
97
|
+
return if Dir.exist?(path)
|
|
98
|
+
sleep(time)
|
|
102
99
|
end
|
|
100
|
+
raise "Directory not found: #{path}"
|
|
101
|
+
rescue => e
|
|
102
|
+
puts "Error: #{e.message}"
|
|
103
103
|
end
|
|
104
|
+
end
|
|
104
105
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
def process_container(name, version, port, env, manifest)
|
|
107
|
+
env_path = "/var/harbr/containers/#{name}/#{env}"
|
|
108
|
+
system "sv stop #{env}.#{name}" if env == 'next'
|
|
109
|
+
|
|
110
|
+
bundle_install_if_needed(env_path)
|
|
111
|
+
create_runit_scripts(name, port, env)
|
|
112
|
+
link_directories(name, version, env)
|
|
113
|
+
sync_live_data_if_next(name) if env == 'next'
|
|
109
114
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
+
containers = collate_containers("#{env}.#{name}", "#{env}.#{manifest.host}", port)
|
|
116
|
+
create_traefik_config(containers)
|
|
117
|
+
puts "harbr: #{version} of #{name} in #{env} environment"
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def bundle_install_if_needed(path)
|
|
121
|
+
Dir.chdir(path) do
|
|
122
|
+
if File.exist?("Gemfile")
|
|
123
|
+
`bundle config set --local path 'vendor/bundle'`
|
|
124
|
+
system "bundle install"
|
|
115
125
|
end
|
|
116
126
|
end
|
|
117
127
|
end
|
|
118
128
|
|
|
119
|
-
def
|
|
120
|
-
|
|
129
|
+
def create_runit_scripts(name, port, env)
|
|
130
|
+
run_script = Runit::Script.new(name, port, env).run_script
|
|
131
|
+
finish_script = Runit::Script.new(name, port, env).finish_script
|
|
132
|
+
log_script = Runit::Script.new(name, port, env).log_script
|
|
133
|
+
|
|
134
|
+
write_to_file "/etc/sv/harbr/#{name}/#{env}/run", run_script
|
|
135
|
+
write_to_file "/etc/sv/harbr/#{name}/#{env}/finish", finish_script
|
|
136
|
+
write_to_file "/etc/sv/harbr/#{name}/#{env}/log/run", log_script
|
|
137
|
+
|
|
138
|
+
`chmod +x /etc/sv/harbr/#{name}/#{env}/run`
|
|
139
|
+
`chmod +x /etc/sv/harbr/#{name}/#{env}/log/run`
|
|
140
|
+
`chmod +x /etc/sv/harbr/#{name}/#{env}/finish`
|
|
121
141
|
end
|
|
122
142
|
|
|
123
|
-
def
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
143
|
+
def link_directories(name, version, env)
|
|
144
|
+
`rm -f /etc/service/#{env}.#{name}`
|
|
145
|
+
`rm -f /var/harbr/containers/#{name}/#{env}`
|
|
146
|
+
|
|
147
|
+
`ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/#{env}`
|
|
148
|
+
`ln -sf /etc/sv/harbr/#{name}/#{env} /etc/service/#{env}.#{name}`
|
|
128
149
|
end
|
|
129
150
|
|
|
130
|
-
def
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
151
|
+
def sync_live_data_if_next(name)
|
|
152
|
+
`rsync -av /var/dddr/#{name}/live /var/dddr/#{name}/next`
|
|
153
|
+
puts "sync live data to next"
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
module Runit
|
|
158
|
+
class Script
|
|
159
|
+
def initialize(container, port, env)
|
|
160
|
+
@container_name = container
|
|
161
|
+
@port = port
|
|
162
|
+
@env = env
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def run_script
|
|
166
|
+
<<~SCRIPT
|
|
167
|
+
#!/bin/sh
|
|
168
|
+
exec 2>&1
|
|
169
|
+
cd /var/harbr/containers/#{@container_name}/#{@env}
|
|
170
|
+
exec ./exe/run #{@port} #{@env}
|
|
171
|
+
SCRIPT
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
def finish_script
|
|
175
|
+
<<~SCRIPT
|
|
176
|
+
#!/bin/sh
|
|
177
|
+
sleep 3
|
|
178
|
+
`lsof -i :#{@port} | awk 'NR!=1 {print $2}' | xargs kill`
|
|
179
|
+
SCRIPT
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def log_script
|
|
183
|
+
<<~SCRIPT
|
|
184
|
+
#!/bin/sh
|
|
185
|
+
exec svlogd -tt /var/log/harbr/#{@container_name}/#{@env}/
|
|
186
|
+
SCRIPT
|
|
160
187
|
end
|
|
161
188
|
end
|
|
162
189
|
end
|
data/lib/harbr/version.rb
CHANGED
data/lib/harbr.rb
CHANGED
|
Binary file
|
|
@@ -10,10 +10,10 @@ creating extconf.h
|
|
|
10
10
|
creating Makefile
|
|
11
11
|
|
|
12
12
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c
|
|
13
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
13
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-wq1vr sitelibdir\=./.gem.20231231-62494-wq1vr clean
|
|
14
14
|
|
|
15
15
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c
|
|
16
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
16
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-wq1vr sitelibdir\=./.gem.20231231-62494-wq1vr
|
|
17
17
|
compiling AbstractMemory.c
|
|
18
18
|
compiling ArrayType.c
|
|
19
19
|
compiling Buffer.c
|
|
@@ -41,8 +41,8 @@ linking shared-object ffi_c.bundle
|
|
|
41
41
|
ld: warning: ignoring duplicate libraries: '-lffi', '-lruby.3.2'
|
|
42
42
|
|
|
43
43
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c
|
|
44
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
45
|
-
/usr/bin/install -c -m 0755 ffi_c.bundle ./.gem.20231231-
|
|
44
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-wq1vr sitelibdir\=./.gem.20231231-62494-wq1vr install
|
|
45
|
+
/usr/bin/install -c -m 0755 ffi_c.bundle ./.gem.20231231-62494-wq1vr
|
|
46
46
|
|
|
47
47
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/ffi-1.16.3/ext/ffi_c
|
|
48
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
48
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-wq1vr sitelibdir\=./.gem.20231231-62494-wq1vr clean
|
|
@@ -3,14 +3,14 @@ current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/js
|
|
|
3
3
|
creating Makefile
|
|
4
4
|
|
|
5
5
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/ext/json
|
|
6
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
6
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-now5mp sitelibdir\=./.gem.20231231-62494-now5mp clean
|
|
7
7
|
|
|
8
8
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/ext/json
|
|
9
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
9
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-now5mp sitelibdir\=./.gem.20231231-62494-now5mp
|
|
10
10
|
make: Nothing to be done for `all'.
|
|
11
11
|
|
|
12
12
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/ext/json
|
|
13
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
13
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-now5mp sitelibdir\=./.gem.20231231-62494-now5mp install
|
|
14
14
|
|
|
15
15
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/json-2.7.0/ext/json
|
|
16
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
16
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-now5mp sitelibdir\=./.gem.20231231-62494-now5mp clean
|
data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/json-2.7.0/json/ext/generator.bundle
CHANGED
|
Binary file
|
data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/json-2.7.0/json/ext/parser.bundle
CHANGED
|
Binary file
|
|
@@ -3,17 +3,17 @@ current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/ra
|
|
|
3
3
|
creating Makefile
|
|
4
4
|
|
|
5
5
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/ext/racc/cparse
|
|
6
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
6
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-xii95s sitelibdir\=./.gem.20231231-62494-xii95s clean
|
|
7
7
|
|
|
8
8
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/ext/racc/cparse
|
|
9
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
9
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-xii95s sitelibdir\=./.gem.20231231-62494-xii95s
|
|
10
10
|
compiling cparse.c
|
|
11
11
|
linking shared-object racc/cparse.bundle
|
|
12
12
|
ld: warning: ignoring duplicate libraries: '-lruby.3.2'
|
|
13
13
|
|
|
14
14
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/ext/racc/cparse
|
|
15
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
16
|
-
/usr/bin/install -c -m 0755 cparse.bundle ./.gem.20231231-
|
|
15
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-xii95s sitelibdir\=./.gem.20231231-62494-xii95s install
|
|
16
|
+
/usr/bin/install -c -m 0755 cparse.bundle ./.gem.20231231-62494-xii95s/racc
|
|
17
17
|
|
|
18
18
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/racc-1.7.3/ext/racc/cparse
|
|
19
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
19
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-xii95s sitelibdir\=./.gem.20231231-62494-xii95s clean
|
data/vendor/bundle/ruby/3.2.0/extensions/arm64-darwin-23/3.2.0/racc-1.7.3/racc/cparse.bundle
CHANGED
|
Binary file
|
|
@@ -3,10 +3,10 @@ current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/sd
|
|
|
3
3
|
creating Makefile
|
|
4
4
|
|
|
5
5
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/sdbm-1.0.0/ext/sdbm
|
|
6
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
6
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-3b4u61 sitelibdir\=./.gem.20231231-62494-3b4u61 clean
|
|
7
7
|
|
|
8
8
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/sdbm-1.0.0/ext/sdbm
|
|
9
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
9
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-3b4u61 sitelibdir\=./.gem.20231231-62494-3b4u61
|
|
10
10
|
compiling _sdbm.c
|
|
11
11
|
compiling init.c
|
|
12
12
|
init.c:76:1: warning: function 'closed_sdbm' could be declared with attribute 'noreturn' [-Wmissing-noreturn]
|
|
@@ -17,8 +17,8 @@ linking shared-object sdbm.bundle
|
|
|
17
17
|
ld: warning: ignoring duplicate libraries: '-lruby.3.2'
|
|
18
18
|
|
|
19
19
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/sdbm-1.0.0/ext/sdbm
|
|
20
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
21
|
-
/usr/bin/install -c -m 0755 sdbm.bundle ./.gem.20231231-
|
|
20
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-3b4u61 sitelibdir\=./.gem.20231231-62494-3b4u61 install
|
|
21
|
+
/usr/bin/install -c -m 0755 sdbm.bundle ./.gem.20231231-62494-3b4u61
|
|
22
22
|
|
|
23
23
|
current directory: /Users/db/Lab/projects/harbr/vendor/bundle/ruby/3.2.0/gems/sdbm-1.0.0/ext/sdbm
|
|
24
|
-
make DESTDIR\= sitearchdir\=./.gem.20231231-
|
|
24
|
+
make DESTDIR\= sitearchdir\=./.gem.20231231-62494-3b4u61 sitelibdir\=./.gem.20231231-62494-3b4u61 clean
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
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.1.
|
|
4
|
+
version: 0.1.42
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Delaney Kuldvee Burke
|
|
@@ -149,7 +149,6 @@ files:
|
|
|
149
149
|
- lib/harbr.rb
|
|
150
150
|
- lib/harbr/container.rb
|
|
151
151
|
- lib/harbr/job.rb
|
|
152
|
-
- lib/harbr/next/job.rb
|
|
153
152
|
- lib/harbr/version.rb
|
|
154
153
|
- sig/harbr.rbs
|
|
155
154
|
- vendor/bundle/ruby/3.2.0/bin/bundle
|
data/lib/harbr/next/job.rb
DELETED
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
require "yaml"
|
|
2
|
-
require "ostruct"
|
|
3
|
-
require "sucker_punch"
|
|
4
|
-
|
|
5
|
-
require "harbr"
|
|
6
|
-
module Harbr
|
|
7
|
-
module Next
|
|
8
|
-
class Job
|
|
9
|
-
include SuckerPunch::Job
|
|
10
|
-
|
|
11
|
-
def get_container_name(path)
|
|
12
|
-
File.basename(path)
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def create_traefik_config(containers)
|
|
16
|
-
config = {
|
|
17
|
-
"http" => {
|
|
18
|
-
"routers" => {
|
|
19
|
-
"traefik-dashboard" => {
|
|
20
|
-
"rule" => "Host(`traefik.harbr.zero2one.ee`)",
|
|
21
|
-
"service" => "api@internal",
|
|
22
|
-
"tls" => {} # Enable TLS for the dashboard
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
"services" => {}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
containers.each do |container|
|
|
30
|
-
container.ip = "127.0.0.1"
|
|
31
|
-
name = container.name.tr(".", "-")
|
|
32
|
-
|
|
33
|
-
# Create the router with TLS enabled and specific format
|
|
34
|
-
router_key = "#{name}-router-secure"
|
|
35
|
-
config["http"]["routers"][router_key] = {
|
|
36
|
-
"rule" => "Host(`#{container.host_header}`)",
|
|
37
|
-
"service" => "#{name}-service",
|
|
38
|
-
"entryPoints" => ["https"],
|
|
39
|
-
"tls" => {
|
|
40
|
-
"certResolver" => "myresolver" # Use a custom certificate resolver
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
# Create the service
|
|
45
|
-
config["http"]["services"]["#{name}-service"] = {
|
|
46
|
-
"loadBalancer" => {
|
|
47
|
-
"servers" => [{"url" => "http://#{container.ip}:#{container.port}"}]
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# Write the configuration to a TOML file
|
|
53
|
-
File.write("/etc/traefik/harbr.toml", TomlRB.dump(config))
|
|
54
|
-
puts "Traefik configuration written to /etc/traefik/harbr.toml"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def collate_containers(name, host, port)
|
|
58
|
-
containers = Harbr::Container::Repository.new
|
|
59
|
-
container = containers.find_by_header(host)
|
|
60
|
-
|
|
61
|
-
if container.nil?
|
|
62
|
-
container = Harbr::Container.new
|
|
63
|
-
container.name = name
|
|
64
|
-
container.host_header = host
|
|
65
|
-
container.ip = "127.0.0.1"
|
|
66
|
-
container.port = port
|
|
67
|
-
containers.create(container)
|
|
68
|
-
else
|
|
69
|
-
container.port = port
|
|
70
|
-
containers.update(container)
|
|
71
|
-
end
|
|
72
|
-
containers.all
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
module Runit
|
|
76
|
-
class Run
|
|
77
|
-
def initialize(container, port)
|
|
78
|
-
@container_name = container
|
|
79
|
-
@port = port
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def to_s
|
|
83
|
-
<<~SCRIPT
|
|
84
|
-
#!/bin/sh
|
|
85
|
-
exec 2>&1
|
|
86
|
-
cd /var/harbr/#{@container_name}/current
|
|
87
|
-
exec ./exe/run #{@port} live
|
|
88
|
-
SCRIPT
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def link
|
|
92
|
-
"ln -s /etc/sv/harbr/#{@container_name} /etc/service/#{@container_name}"
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
class Finish
|
|
97
|
-
def initialize(port)
|
|
98
|
-
@port = port
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
def to_s
|
|
102
|
-
<<~SCRIPT
|
|
103
|
-
#!/bin/sh
|
|
104
|
-
sleep 3
|
|
105
|
-
`lsof -i :#{@port} | awk 'NR!=1 {print $2}' | xargs kill`
|
|
106
|
-
SCRIPT
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
class Log
|
|
111
|
-
def initialize(container, port)
|
|
112
|
-
@container_name = container
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
def to_s
|
|
116
|
-
<<~SCRIPT
|
|
117
|
-
#!/bin/sh
|
|
118
|
-
exec svlogd -tt /var/log/harbr/#{@container_name}/next/
|
|
119
|
-
SCRIPT
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
module Next
|
|
124
|
-
class Run
|
|
125
|
-
def initialize(container, port)
|
|
126
|
-
@container_name = container
|
|
127
|
-
@port = port
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
def to_s
|
|
131
|
-
<<~SCRIPT
|
|
132
|
-
#!/bin/sh
|
|
133
|
-
exec 2>&1
|
|
134
|
-
cd /var/harbr/containers/#{@container_name}/next
|
|
135
|
-
exec ./exe/run #{@port} next
|
|
136
|
-
SCRIPT
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
class Log
|
|
141
|
-
def initialize(container)
|
|
142
|
-
@container_name = container
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def to_s
|
|
146
|
-
<<~SCRIPT
|
|
147
|
-
#!/bin/sh
|
|
148
|
-
exec svlogd -tt /var/log/harbr/#{@container_name}/next/
|
|
149
|
-
SCRIPT
|
|
150
|
-
end
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def write_to_file(path, contents)
|
|
156
|
-
File.write(path, contents)
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
def load_manifest(container, version)
|
|
160
|
-
manifest_path = "/var/harbr/containers/#{container}/versions/#{version}/config/manifest.yml"
|
|
161
|
-
raise "Manifest not found at #{manifest_path}" unless File.exist?(manifest_path)
|
|
162
|
-
manifest_data = YAML.load_file(manifest_path)
|
|
163
|
-
OpenStruct.new(manifest_data)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def perform(name, version)
|
|
167
|
-
Harbr.notifiable(name, version) do
|
|
168
|
-
manifest = load_manifest(name, version)
|
|
169
|
-
current_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
|
170
|
-
|
|
171
|
-
port = `port assign next.#{manifest.port}`.strip
|
|
172
|
-
|
|
173
|
-
Dir.chdir current_path do
|
|
174
|
-
system "sv stop next.#{name}"
|
|
175
|
-
if File.exist?("Gemfile")
|
|
176
|
-
`bundle config set --local path 'vendor/bundle'`
|
|
177
|
-
system "bundle install"
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
`mkdir -p /etc/sv/harbr/#{name}/next`
|
|
181
|
-
`mkdir -p /etc/sv/harbr/#{name}/next/log`
|
|
182
|
-
`mkdir -p /var/log/harbr/#{name}/next/log`
|
|
183
|
-
|
|
184
|
-
write_to_file "/etc/sv/harbr/#{name}/next/run", Runit::Next::Run.new(name, port).to_s
|
|
185
|
-
write_to_file "/etc/sv/harbr/#{name}/next/finish", Runit::Finish.new(port).to_s
|
|
186
|
-
write_to_file "/etc/sv/harbr/#{name}/next/log/run", Runit::Next::Log.new(name).to_s
|
|
187
|
-
|
|
188
|
-
`chmod +x /etc/sv/harbr/#{name}/next/run`
|
|
189
|
-
`chmod +x /etc/sv/harbr/#{name}/next/log/run`
|
|
190
|
-
`chmod +x /etc/sv/harbr/#{name}/next/finish`
|
|
191
|
-
|
|
192
|
-
system "rm /etc/service/next.#{name}"
|
|
193
|
-
system "rm /var/harbr/containers/#{name}/next"
|
|
194
|
-
|
|
195
|
-
system "ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next"
|
|
196
|
-
system "ln -sf /etc/sv/harbr/#{name}/next /etc/service/next.#{name}"
|
|
197
|
-
|
|
198
|
-
`rsync -av /var/dddr/#{name}/live /var/dddr/#{name}/next`
|
|
199
|
-
puts "sync live data to next"
|
|
200
|
-
|
|
201
|
-
system "sv restart next.#{name}"
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
containers = collate_containers("next.#{name}", "next.#{manifest.host}", port)
|
|
205
|
-
create_traefik_config(containers)
|
|
206
|
-
puts "harbr: #{version} of #{name} into next environment"
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|