harbr 0.0.78 → 0.0.81
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/harbr +3 -3
- data/lib/harbr/job.rb +1 -15
- data/lib/harbr/next/job.rb +32 -56
- data/lib/harbr/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b35165cb2f91631af1af3f62bb4d32308d0ca1ca10b1325e984cb77d5685bc5
|
4
|
+
data.tar.gz: cd1214d2cf6c2ecb58592e90bc6de7f5e762f9b5a33da318549186ebbd9e5d7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9b79e33d8fc19698fc6b11b10c0e0f2796d709c9fdf4f7d41cfc1eeb8fc3430b47d90cd998bcbe73856dc7d63a6969488d7ec7a7c39814800a69ecaecc954d7
|
7
|
+
data.tar.gz: 682ebf832dc4649f42e60f1cc128df9dd1903ee6c2e435d125754f1026ac3c918d15fba1c2ac75d38811c7116e3928043c807163a6e4f4f4fea32e7945af702b
|
data/exe/harbr
CHANGED
@@ -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
|
@@ -176,7 +176,7 @@ class HarbrCLI < Thor
|
|
176
176
|
|
177
177
|
loop do
|
178
178
|
current_state = scan_for_containers
|
179
|
-
new_versions = current_state.keys - last_known_state.
|
179
|
+
new_versions = current_state.keys - last_known_state.keys
|
180
180
|
|
181
181
|
new_versions.each do |container_version|
|
182
182
|
container, version = container_version.split("/versions/")
|
data/lib/harbr/job.rb
CHANGED
@@ -12,21 +12,7 @@ module Harbr
|
|
12
12
|
File.basename(path)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
file_path = '/var/harbr/.data/processed_next.txt' # replace with your file path
|
17
|
-
`touch #{file_path}`
|
18
|
-
container_version = "#{name},#{version}"
|
19
|
-
|
20
|
-
File.open(file_path, 'r') do |file|
|
21
|
-
if file.any? { |line| line.chomp == container_version }
|
22
|
-
puts 'containerised'
|
23
|
-
else
|
24
|
-
result = yield name, version
|
25
|
-
File.write(file_path, "#{container_version}\n", mode: 'a') unless result == false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
15
|
+
|
30
16
|
def create_traefik_config(containers)
|
31
17
|
config = {
|
32
18
|
"http" => {
|
data/lib/harbr/next/job.rb
CHANGED
@@ -12,25 +12,11 @@ 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
|
19
19
|
|
20
|
-
def check_container_version(name, version)
|
21
|
-
file_path = '/var/harbr/.data/processed_next.txt' # replace with your file path
|
22
|
-
`touch #{file_path}`
|
23
|
-
container_version = "#{name},#{version}"
|
24
|
-
|
25
|
-
File.open(file_path, 'r') do |file|
|
26
|
-
if file.any? { |line| line.chomp == container_version }
|
27
|
-
puts 'containerised'
|
28
|
-
else
|
29
|
-
result = yield name, version
|
30
|
-
File.write(file_path, "#{container_version}\n", mode: 'a') unless result == false
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
20
|
|
35
21
|
def create_traefik_config(containers)
|
36
22
|
config = {
|
@@ -182,51 +168,41 @@ module Harbr
|
|
182
168
|
OpenStruct.new(manifest_data)
|
183
169
|
end
|
184
170
|
|
185
|
-
def perform
|
171
|
+
def perform(name, version)
|
186
172
|
`bundle config set --local path 'vendor/bundle'`
|
187
173
|
|
188
|
-
|
189
|
-
|
174
|
+
manifest = load_manifest(name,version)
|
175
|
+
current_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
176
|
+
|
177
|
+
port = `port assign next.#{manifest.port}`.strip
|
178
|
+
|
179
|
+
Dir.chdir current_path do
|
180
|
+
|
181
|
+
system "sv stop #{name}"
|
182
|
+
system "bundle install"
|
183
|
+
|
184
|
+
`mkdir -p /etc/sv/harbr/#{name}/next`
|
185
|
+
`mkdir -p /etc/sv/harbr/#{name}/next/log`
|
186
|
+
`mkdir -p /var/log/harbr/#{name}/next/log`
|
187
|
+
|
188
|
+
write_to_file "/etc/sv/harbr/#{name}/next/run", Runit::Next::Run.new(name,port).to_s
|
189
|
+
write_to_file "/etc/sv/harbr/#{name}/next/finish", Runit::Finish.new(port).to_s
|
190
|
+
write_to_file "/etc/sv/harbr/#{name}/next/log/run", Runit::Next::Log.new(name).to_s
|
190
191
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
Dir.chdir current_path do
|
202
|
-
|
203
|
-
system "sv stop #{name}"
|
204
|
-
system "bundle install"
|
205
|
-
|
206
|
-
`mkdir -p /etc/sv/harbr/#{name}/next`
|
207
|
-
`mkdir -p /etc/sv/harbr/#{name}/next/log`
|
208
|
-
`mkdir -p /var/log/harbr/#{name}/next/log`
|
209
|
-
|
210
|
-
write_to_file "/etc/sv/harbr/#{name}/next/run", Runit::Next::Run.new(name,port).to_s
|
211
|
-
write_to_file "/etc/sv/harbr/#{name}/next/finish", Runit::Finish.new(port).to_s
|
212
|
-
write_to_file "/etc/sv/harbr/#{name}/next/log/run", Runit::Next::Log.new(name).to_s
|
213
|
-
|
214
|
-
`chmod +x /etc/sv/harbr/#{name}/next/run`
|
215
|
-
`chmod +x /etc/sv/harbr/#{name}/next/log/run`
|
216
|
-
`chmod +x /etc/sv/harbr/#{name}/next/finish`
|
217
|
-
|
218
|
-
|
219
|
-
system "ln -s /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next"
|
220
|
-
system "ln -s /etc/sv/harbr/#{name}/next /etc/service/next.#{name}"
|
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
|
192
|
+
`chmod +x /etc/sv/harbr/#{name}/next/run`
|
193
|
+
`chmod +x /etc/sv/harbr/#{name}/next/log/run`
|
194
|
+
`chmod +x /etc/sv/harbr/#{name}/next/finish`
|
195
|
+
|
196
|
+
|
197
|
+
system "ln -s /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/next"
|
198
|
+
system "ln -s /etc/sv/harbr/#{name}/next /etc/service/next.#{name}"
|
199
|
+
|
200
|
+
containers = collate_containers("next.#{name}","next.#{manifest.host}",port)
|
201
|
+
create_traefik_config(containers)
|
228
202
|
end
|
229
|
-
|
203
|
+
|
204
|
+
puts "process #{version} of #{name}"
|
205
|
+
|
230
206
|
end
|
231
207
|
|
232
208
|
end
|
data/lib/harbr/version.rb
CHANGED