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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cfbe8ee63ba9673159a4cbe99bff5508886e603274bdfe7eca373e4fad1cf1d
4
- data.tar.gz: 27e468bb49b774ecb556fa6553e9b2134a98a06c7e3bd3a312cb45c848ddfc5d
3
+ metadata.gz: 3b35165cb2f91631af1af3f62bb4d32308d0ca1ca10b1325e984cb77d5685bc5
4
+ data.tar.gz: cd1214d2cf6c2ecb58592e90bc6de7f5e762f9b5a33da318549186ebbd9e5d7e
5
5
  SHA512:
6
- metadata.gz: 53e4d7f9397d59ecfd496c717b1fb983f29cd6b1c2a81ba9225cae566c8c1f09d8f99ab1e3c3bb5ed3c4897eee7f738f76a65b79b6b2216ad4d6fc1521c75783
7
- data.tar.gz: 1dca696d45363ca0645f94b8b6813d9f8c6e1e3d4b86e734a8f585c0371cd86867c1e06dc0fb817bde2c3bc9fbe92b2cbd1c39c1d3480323d6f7fb9d8f65b3b3
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
- run_tasks(container, version)
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 run_tasks(container, version)
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.keysß
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
- def check_container_version(name, version)
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" => {
@@ -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
- Dir.glob('/var/harbr/containers/*').select { |f| File.directory? f }.each do |container_path|
189
- latest_version = highest_numbered_directory("#{container_path}/versions")
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
- version = get_container_name(latest_version)
192
- name = get_container_name(container_path)
193
- manifest = load_manifest(name,version)
194
-
195
- check_container_version(name, version) do
196
-
197
- current_path = "/var/harbr/containers/#{name}/versions/#{version}"
198
-
199
- port = `port assign next.#{manifest.port}`.strip
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Harbr
4
- VERSION = "0.0.78"
4
+ VERSION = "0.0.81"
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.78
4
+ version: 0.0.81
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke