harbr 0.0.77 → 0.0.80
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/harbr +6 -7
- data/lib/harbr/next/job.rb +38 -43
- data/lib/harbr/version.rb +1 -1
- data/lib/harbr.rb +2 -79
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faf169d8747490a5212c404ba4ae0ccf82009544bb5d0b6b0e888d425cba64a4
|
4
|
+
data.tar.gz: 35b2f2767321282d31d24bd37b6e6d811c235dde939eed1c50e4ae2fad8e3f98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d61e0272279a4c362d282771e0b155022b47dc40ef514a760b51e4d5c90e1785891e02e806da5261c1845d411d5a5ab8abce4e2bf5af24ee6b7db6fc6aef8a3d
|
7
|
+
data.tar.gz: cedb23c1d39e632d24d4cfbeb377474a763b5bfdcc2d7430ee49c120c672fb70e6704d954f8bf724b506289f051fd3f30a842f887db326156f52712c083a1feb
|
data/exe/harbr
CHANGED
@@ -43,7 +43,7 @@ class HarbrCLI < Thor
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def scan_for_containers
|
46
|
-
Dir.glob("/var/harbr/*").each_with_object({}) do |container_path, hash|
|
46
|
+
Dir.glob("/var/harbr/containers/*").each_with_object({}) do |container_path, hash|
|
47
47
|
next unless File.directory?(container_path)
|
48
48
|
container_name = File.basename(container_path)
|
49
49
|
versions = Dir.glob("#{container_path}/versions/*").select { |path| File.directory?(path) }
|
@@ -60,12 +60,12 @@ class HarbrCLI < Thor
|
|
60
60
|
puts "Container '#{container}', Version '#{version}' is already placed."
|
61
61
|
else
|
62
62
|
puts "Placing container: '#{container}', Version: '#{version}'"
|
63
|
-
|
63
|
+
run_jobs(container, version)
|
64
64
|
File.open(PLACED_FILE, "a") { |file| file.puts("#{container}/#{version}") }
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
-
def
|
68
|
+
def run_jobs(container, version)
|
69
69
|
puts "Running tasks for container: #{container}, version: #{version}"
|
70
70
|
puts "waiting for 3 seconds"
|
71
71
|
sleep 3
|
@@ -76,7 +76,6 @@ class HarbrCLI < Thor
|
|
76
76
|
else
|
77
77
|
Harbr::Next::Job.perform_async(container, version)
|
78
78
|
puts "deploy next version #{version} of #{container}"
|
79
|
-
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
@@ -154,7 +153,7 @@ class HarbrCLI < Thor
|
|
154
153
|
desc "setup", "Set up Harbr environment"
|
155
154
|
def setup
|
156
155
|
# Check and create /var/harbr directory
|
157
|
-
check_and_create_directory("/var/harbr")
|
156
|
+
check_and_create_directory("/var/harbr/containers")
|
158
157
|
|
159
158
|
# Check for Ruby, Traefik, and runit, and install if necessary
|
160
159
|
install_with_snap("ruby") unless command_exists?("ruby")
|
@@ -170,9 +169,9 @@ class HarbrCLI < Thor
|
|
170
169
|
display_containers_table(container_repo.all)
|
171
170
|
end
|
172
171
|
|
173
|
-
desc "monitor", "Monitor /var/harbr for new container versions"
|
172
|
+
desc "monitor", "Monitor /var/harbr/comtainers for new container versions"
|
174
173
|
def monitor
|
175
|
-
puts "Monitoring /var/harbr for new container versions..."
|
174
|
+
puts "Monitoring /var/harbr/containers for new container versions..."
|
176
175
|
last_known_state = {}
|
177
176
|
|
178
177
|
loop do
|
data/lib/harbr/next/job.rb
CHANGED
@@ -12,7 +12,7 @@ module Harbr
|
|
12
12
|
directories = Dir.glob("#{path}/*").select { |entry| File.directory?(entry) }
|
13
13
|
directories.max_by { |entry| entry[/\d+/].to_i }
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
def get_container_name(path)
|
17
17
|
File.basename(path)
|
18
18
|
end
|
@@ -182,51 +182,46 @@ module Harbr
|
|
182
182
|
OpenStruct.new(manifest_data)
|
183
183
|
end
|
184
184
|
|
185
|
-
def perform
|
185
|
+
def perform(name, version)
|
186
186
|
`bundle config set --local path 'vendor/bundle'`
|
187
|
-
|
188
|
-
|
189
|
-
|
187
|
+
|
188
|
+
container_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
189
|
+
latest_version = highest_numbered_directory("#{container_path}/versions")
|
190
190
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
containers = collate_containers("next.#{name}","next.#{manifest.host}",port)
|
223
|
-
create_traefik_config(containers)
|
224
|
-
end
|
225
|
-
|
226
|
-
puts "process #{version} of #{name}"
|
227
|
-
end
|
191
|
+
version = get_container_name(latest_version)
|
192
|
+
name = get_container_name(container_path)
|
193
|
+
manifest = load_manifest(name,version)
|
194
|
+
current_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
195
|
+
|
196
|
+
port = `port assign next.#{manifest.port}`.strip
|
197
|
+
|
198
|
+
Dir.chdir current_path do
|
199
|
+
|
200
|
+
system "sv stop #{name}"
|
201
|
+
system "bundle install"
|
202
|
+
|
203
|
+
`mkdir -p /etc/sv/harbr/#{name}/next`
|
204
|
+
`mkdir -p /etc/sv/harbr/#{name}/next/log`
|
205
|
+
`mkdir -p /var/log/harbr/#{name}/next/log`
|
206
|
+
|
207
|
+
write_to_file "/etc/sv/harbr/#{name}/next/run", Runit::Next::Run.new(name,port).to_s
|
208
|
+
write_to_file "/etc/sv/harbr/#{name}/next/finish", Runit::Finish.new(port).to_s
|
209
|
+
write_to_file "/etc/sv/harbr/#{name}/next/log/run", Runit::Next::Log.new(name).to_s
|
210
|
+
|
211
|
+
`chmod +x /etc/sv/harbr/#{name}/next/run`
|
212
|
+
`chmod +x /etc/sv/harbr/#{name}/next/log/run`
|
213
|
+
`chmod +x /etc/sv/harbr/#{name}/next/finish`
|
214
|
+
|
215
|
+
|
216
|
+
system "ln -s /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next"
|
217
|
+
system "ln -s /etc/sv/harbr/#{name}/next /etc/service/next.#{name}"
|
218
|
+
|
219
|
+
containers = collate_containers("next.#{name}","next.#{manifest.host}",port)
|
220
|
+
create_traefik_config(containers)
|
228
221
|
end
|
229
|
-
|
222
|
+
|
223
|
+
puts "process #{version} of #{name}"
|
224
|
+
|
230
225
|
end
|
231
226
|
|
232
227
|
end
|
data/lib/harbr/version.rb
CHANGED
data/lib/harbr.rb
CHANGED
@@ -14,7 +14,7 @@ require_relative "harbr/next/job"
|
|
14
14
|
|
15
15
|
# Harbr module for managing containers, jobs, ports, and 2s
|
16
16
|
module Harbr
|
17
|
-
DEFAULT_DIRECTORY = "/var/harbr"
|
17
|
+
DEFAULT_DIRECTORY = "/var/harbr/containers"
|
18
18
|
DEFAULT_DIRECTORY_DATA_DIR = "#{DEFAULT_DIRECTORY}/.data"
|
19
19
|
class Error < StandardError; end
|
20
20
|
|
@@ -22,84 +22,7 @@ module Harbr
|
|
22
22
|
directories = Dir.glob("#{path}/*").select { |entry| File.directory?(entry) }
|
23
23
|
directories.max_by { |entry| entry[/\d+/].to_i }
|
24
24
|
end
|
25
|
-
|
26
|
-
module Runit
|
27
|
-
class Run
|
28
|
-
def initialize(container, port)
|
29
|
-
@container_name = container
|
30
|
-
@port = port
|
31
|
-
end
|
32
|
-
|
33
|
-
def to_s
|
34
|
-
<<~SCRIPT
|
35
|
-
#!/bin/sh
|
36
|
-
exec 2>&1
|
37
|
-
cd /var/harbr/#{@container_name}/current
|
38
|
-
exec ./exe/run #{@port}
|
39
|
-
SCRIPT
|
40
|
-
end
|
41
|
-
|
42
|
-
def link
|
43
|
-
"ln -s /etc/sv/harbr/#{@container_name} /etc/service/#{@container_name}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Log
|
48
|
-
def initialize(container, port)
|
49
|
-
@container_name = container
|
50
|
-
end
|
51
|
-
|
52
|
-
def to_s
|
53
|
-
<<~SCRIPT
|
54
|
-
#!/bin/sh
|
55
|
-
exec svlogd -tt /var/log/harbr/#{@container_name}/next/
|
56
|
-
SCRIPT
|
57
|
-
end
|
58
|
-
|
59
|
-
def link
|
60
|
-
"ln -s /etc/sv/harbr/#{@container_name}/log /etc/service/#{@container_name}/log"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
module Next
|
65
|
-
class Run
|
66
|
-
def initialize(container, port)
|
67
|
-
@container_name = container
|
68
|
-
@port = port
|
69
|
-
end
|
70
|
-
|
71
|
-
def to_s
|
72
|
-
<<~SCRIPT
|
73
|
-
#!/bin/sh
|
74
|
-
exec 2>&1
|
75
|
-
cd /var/harbr/#{@container_name}/next
|
76
|
-
exec ./exe/run #{@port}
|
77
|
-
SCRIPT
|
78
|
-
end
|
79
|
-
|
80
|
-
def link
|
81
|
-
"ln -s /etc/sv/harbr/#{@container_name}/next /etc/service/next.#{@container_name}"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class Log
|
86
|
-
def initialize(container, port)
|
87
|
-
@container_name = container
|
88
|
-
end
|
89
|
-
|
90
|
-
def to_s
|
91
|
-
<<~SCRIPT
|
92
|
-
#!/bin/sh
|
93
|
-
exec svlogd -tt /var/log/harbr/#{@container_name}/next/
|
94
|
-
SCRIPT
|
95
|
-
end
|
96
|
-
|
97
|
-
def link
|
98
|
-
"ln -s /etc/sv/harbr/#{container_name}/next/log/ /etc/service/next.#{container_name}/log"
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
25
|
+
|
103
26
|
end
|
104
27
|
|
105
28
|
Dddr.configure do |config|
|
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.80
|
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-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|