harbr 0.1.83 → 0.1.85

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: facdcd11bc99e8446e63f238f26887c463b3e43e1774a3d55e01b84db1deb544
4
- data.tar.gz: 57e4363de2ae148056ae3c68b7bb5018e8860630cd54feda08d91d267e17f2e1
3
+ metadata.gz: be82c631f5f11bd9bd9b0e2f418a649a3c9be0c9917cc4659fbcaac615b4b44e
4
+ data.tar.gz: 8714e7e129b71d4db389959256b85f4d1d5786f07b65e9b83ad5396443eea2e6
5
5
  SHA512:
6
- metadata.gz: 6916c71a469ab13b6c67ac85fff8f4668252ae8a670727f273bc71d9394dee07d3d3017f56128a27b49a70450504232338911d26fc1474c062124bfaecd14da9
7
- data.tar.gz: 43fbf57d32578cfe257a65b5308f79607beb2eb50edf4942219852386c81e44d5c9a422b2952eaa1cc2a7683df78382f191b5dd83d57d66fef64873040469a5d
6
+ metadata.gz: 4f6e4de31bf787de45ba4239916ff00552f3bfebcae2e5111e438e5ebb458ccc01865b189d73722383d6ec695042ad2b5d723fdcfeb952c7ee1079de4f3cc7f8
7
+ data.tar.gz: fd75ef1823dcac1a36f1f4db2ceabd60a181253aa197b4a44766a3496d67aeb0fd8c3803e4b9017f4eec3ff095443a88fe65a9de6d070d492afa85cc55f3c184
data/exe/harbr CHANGED
@@ -133,7 +133,8 @@ class HarbrCLI < Thor
133
133
 
134
134
  container_repo = Harbr::Container::Repository.new
135
135
 
136
- [name, "next.#{name}"].each do |container_name|
136
+ ["live.#{name}", "next.#{name}"].each do |container_name|
137
+
137
138
  container_repo.get_by_name(container_name).each do |container|
138
139
  `port release #{container.port}`
139
140
  puts "released port #{container.port} successfully."
@@ -164,7 +165,7 @@ class HarbrCLI < Thor
164
165
  container_repo = Harbr::Container::Repository.new
165
166
  container = container_repo.find_by_name(container)
166
167
  if container
167
- exec "tail -f /var/log/harbr/#{container.name}/current" if options[:live]
168
+ exec "tail -f /var/log/harbr/#{container.name}/live/current" if options[:live]
168
169
  exec "tail -f /var/log/harbr/#{container.name}/next/current" if options[:next]
169
170
  else
170
171
  puts "Container not recognized"
@@ -217,12 +218,12 @@ class HarbrCLI < Thor
217
218
  version = $1
218
219
  raise "Ooops! next version not found!" if version.nil?
219
220
 
220
- /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/current`
221
- `ln -sf /var/harbr/containers/#{name}/version/#{$1} /var/harbr/containers/#{name}/rollback`
221
+ Harbr::Job.perform_async(name, version, "live")
222
222
 
223
- Harbr::Job.perform_async(name, version, "current")
223
+ /versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/live`
224
+ `ln -sf /var/harbr/containers/#{name}/version/#{$1} /var/harbr/containers/#{name}/rollback`
224
225
 
225
- puts "deploy current version #{version} of #{name}"
226
+ puts "deploy version #{version} of #{name} to live environment"
226
227
  end
227
228
 
228
229
  desc "rollback", "rollback last deploy"
@@ -231,9 +232,9 @@ class HarbrCLI < Thor
231
232
  if File.exist?("rollback")
232
233
  Dir.chdir("/var/harbr/containers/#{name}/") do
233
234
  /(?:. * -> (?:.*))/ =~ `ls -l /var/harbr/containers/#{name}/rollback`
234
- `rm -r current`
235
- `ln -sf #{$2} current`
236
- `sv restart #{name}`
235
+ `rm -r live`
236
+ `ln -sf #{$2} live`
237
+ `sv restart live.#{name}`
237
238
  end
238
239
  puts "rollback successful"
239
240
  end
data/lib/harbr/job.rb CHANGED
@@ -132,21 +132,24 @@ module Harbr
132
132
  def process_container(name, version, port, env, manifest)
133
133
  version_path = "/var/harbr/containers/#{name}/versions/#{version}"
134
134
 
135
+ if env == "live"
136
+ `rm -f /var/harbr/containers/#{name}/live` if Dir.exist?("/var/harbr/containers/#{name}/live")
137
+ `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/live`
138
+ end
139
+
135
140
  bundle_install_if_needed(version_path)
136
141
 
137
142
  create_runit_scripts(name, port, env)
138
143
  link_directories(name, version, env)
139
144
  sync_live_data_if_next(name) if env == "next"
140
145
 
141
- containers = collate_containers("#{name}", "#{manifest.host}", port, manifest.host_aliases) if env == "current"
142
- containers = collate_containers("#{env}.#{name}", "#{env}.#{manifest.host}", port, manifest.host_aliases&.map { |host| "#{env}.#{host}" }) if env == "next"
146
+ containers = collate_containers("#{env}.#{name}", "#{env}.#{manifest.host}", port, manifest.host_aliases&.map { |host| "#{env}.#{host}" })
143
147
 
144
148
  create_traefik_config(containers)
145
149
 
146
- system "sv restart #{env}.#{name}" if env == "next"
147
- system "sv restart #{name}" if env == "current"
150
+ system "sv restart #{env}.#{name}"
148
151
 
149
- puts "harbr: #{version} of #{name} in #{env} environment"
152
+ puts "harbr: #{version} of #{name} deployed to #{env} environment"
150
153
  end
151
154
 
152
155
  def bundle_install_if_needed(path)
@@ -165,44 +168,20 @@ module Harbr
165
168
  finish_script = Runit::Script.new(name, port, env).finish_script
166
169
  log_script = Runit::Script.new(name, port, env).log_script
167
170
 
168
- if env == "next"
169
- write_to_file "/etc/sv/harbr/#{name}/#{env}/run", run_script
170
- write_to_file "/etc/sv/harbr/#{name}/#{env}/log/run", log_script
171
- write_to_file "/etc/sv/harbr/#{name}/#{env}/finish", finish_script
172
- `chmod +x /etc/sv/harbr/#{name}/#{env}/run`
173
- `chmod +x /etc/sv/harbr/#{name}/#{env}/finish`
174
- `chmod +x /etc/sv/harbr/#{name}/#{env}/log/run`
175
- `mkdir -p /var/log/harbr/#{name}/#{env}`
176
- end
177
-
178
- if env == "current"
179
- write_to_file "/etc/sv/harbr/#{name}/run", run_script
180
- write_to_file "/etc/sv/harbr/#{name}/log/run", log_script
181
- write_to_file "/etc/sv/harbr/#{name}/finish", finish_script
182
- `chmod +x /etc/sv/harbr/#{name}/run`
183
- `chmod +x /etc/sv/harbr/#{name}/finish`
184
- `chmod +x /etc/sv/harbr/#{name}/log/run`
185
- `mkdir -p /var/log/harbr/#{name}`
186
-
187
- end
171
+ write_to_file "/etc/sv/harbr/#{name}/#{env}/run", run_script
172
+ write_to_file "/etc/sv/harbr/#{name}/#{env}/log/run", log_script
173
+ write_to_file "/etc/sv/harbr/#{name}/#{env}/finish", finish_script
174
+ `chmod +x /etc/sv/harbr/#{name}/#{env}/run`
175
+ `chmod +x /etc/sv/harbr/#{name}/#{env}/finish`
176
+ `chmod +x /etc/sv/harbr/#{name}/#{env}/log/run`
177
+ `mkdir -p /var/log/harbr/#{name}/#{env}`
188
178
  end
189
179
 
190
180
  def link_directories(name, version, env)
191
- if env == "next"
192
- `rm -f /etc/service/#{env}.#{name}`
193
- `rm -f /var/harbr/containers/#{name}/#{env}`
194
- `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/#{env}`
195
- `ln -sf /etc/sv/harbr/#{name}/#{env} /etc/service/#{env}.#{name}`
196
- end
197
-
198
- if env == "current"
199
-
200
- `rm -f /etc/service/#{name}`
201
- `rm -f /var/harbr/containers/#{name}/current`
202
-
203
- `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/current`
204
- `ln -sf /etc/sv/harbr/#{name} /etc/service/#{name}`
205
- end
181
+ `rm -f /etc/service/#{env}.#{name}`
182
+ `rm -f /var/harbr/containers/#{name}/#{env}`
183
+ `ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/#{env}`
184
+ `ln -sf /etc/sv/harbr/#{name}/#{env} /etc/service/#{env}.#{name}`
206
185
  end
207
186
 
208
187
  def sync_live_data_if_next(name)
@@ -238,7 +217,6 @@ module Harbr
238
217
  end
239
218
 
240
219
  def log_script
241
- env = @env == 'current' ? nil : @env
242
220
  <<~SCRIPT
243
221
  #!/bin/sh
244
222
  echo "starting log for #{@container_name} on port #{@port}"
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.1.83"
4
+ VERSION = "0.1.85"
5
5
  end
data/lib/harbr.rb CHANGED
@@ -41,7 +41,6 @@ module Harbr
41
41
 
42
42
  def self.notifiable(name, version, env)
43
43
  yield if block_given?
44
- env = "live" if env == "current"
45
44
  send_notification("Harbr: #{name} deployed to #{env} successfully", "<p>harbr: #{version} of #{name} deployed to #{env} successfully</p>")
46
45
  rescue => e
47
46
  html_content = <<~HTML
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.83
4
+ version: 0.1.85
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delaney Kuldvee Burke