harbr 0.1.79 → 0.1.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 +9 -12
- data/lib/harbr/container.rb +1 -0
- data/lib/harbr/job.rb +17 -25
- data/lib/harbr/version.rb +1 -1
- data/lib/harbr.rb +4 -4
- 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: c8e8c297255708987e6eb96de5b195a839e1e66b9ca42ad2b74bdea404350ed3
|
4
|
+
data.tar.gz: a01591319c5ac05400b18eda6c265055bb8187fa972524465d63e33b5efd30fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74d90e8e3b0c260e62dfd640443b785162f5d637b6fe564ef0af1aabedb116ddfa86ccc89429eed88679844148fba9eeb4bd204a0104400dba62077b97662340
|
7
|
+
data.tar.gz: 293b1f07d5de4337fea92dd693fe83c61940e01c2a981449e5e8ef512b36a7ddf33af833055eb5da44b5ef5f03c01435e4bd9bb63aa27cc8fc25a27b3a6486dd
|
data/exe/harbr
CHANGED
@@ -134,7 +134,6 @@ class HarbrCLI < Thor
|
|
134
134
|
container_repo = Harbr::Container::Repository.new
|
135
135
|
|
136
136
|
[name, "next.#{name}"].each do |container_name|
|
137
|
-
|
138
137
|
container_repo.get_by_name(container_name).each do |container|
|
139
138
|
`port release #{container.port}`
|
140
139
|
puts "released port #{container.port} successfully."
|
@@ -189,18 +188,18 @@ class HarbrCLI < Thor
|
|
189
188
|
SCRIPT
|
190
189
|
|
191
190
|
log_script = <<~SCRIPT
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
191
|
+
#!/bin/sh
|
192
|
+
exec svlogd -tt /var/log/harbr/
|
193
|
+
SCRIPT
|
194
|
+
|
196
195
|
write_to_file("/etc/sv/harbr/run", run_script)
|
197
196
|
write_to_file("/etc/sv/harbr/log/run", log_script)
|
198
|
-
|
197
|
+
|
199
198
|
`chmod +x /etc/sv/harbr/run`
|
200
199
|
`chmod +x /etc/sv/harbr/log/run`
|
201
200
|
`mkdir -p /var/log/harbr`
|
202
201
|
`ln -sf /etc/sv/harbr /etc/service/harbr`
|
203
|
-
`sv start harbr`
|
202
|
+
`sv start harbr`
|
204
203
|
puts "Harbr service started successfully."
|
205
204
|
|
206
205
|
puts "Setup completed successfully."
|
@@ -214,20 +213,18 @@ class HarbrCLI < Thor
|
|
214
213
|
|
215
214
|
desc "deploy", "deploy a container to production"
|
216
215
|
def deploy(name)
|
217
|
-
/versions\/(?<version>\d*)
|
216
|
+
/versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/next`
|
218
217
|
version = $1
|
219
218
|
raise "Ooops! next version not found!" if version.nil?
|
220
|
-
|
221
|
-
/versions\/(?<version>\d*)
|
219
|
+
|
220
|
+
/versions\/(?<version>\d*)/ =~ `ls -l /var/harbr/containers/#{name}/current`
|
222
221
|
`ln -sf /var/harbr/containers/#{name}/version/#{$1} /var/harbr/containers/#{name}/rollback`
|
223
222
|
|
224
223
|
Harbr::Job.perform_async(name, version, "current")
|
225
224
|
|
226
225
|
puts "deploy current version #{version} of #{name}"
|
227
|
-
|
228
226
|
end
|
229
227
|
|
230
|
-
|
231
228
|
desc "rollback", "rollback last deploy"
|
232
229
|
def rollback(name)
|
233
230
|
Dir.chdir("/var/harbr/containers/#{name}") do
|
data/lib/harbr/container.rb
CHANGED
data/lib/harbr/job.rb
CHANGED
@@ -56,7 +56,7 @@ module Harbr
|
|
56
56
|
containers.update(container)
|
57
57
|
end
|
58
58
|
|
59
|
-
if
|
59
|
+
if host_header_aliases
|
60
60
|
host_header_aliases.each do |host_header_alias|
|
61
61
|
container = Harbr::Container.new
|
62
62
|
container.name = "#{name} -> #{host_header_alias}"
|
@@ -70,7 +70,6 @@ module Harbr
|
|
70
70
|
containers.all
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
73
|
def write_to_file(path, contents)
|
75
74
|
dirname = File.dirname(path)
|
76
75
|
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
@@ -87,10 +86,10 @@ module Harbr
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def perform(name, version, env)
|
90
|
-
Harbr.notifiable(name, version,env) do
|
89
|
+
Harbr.notifiable(name, version, env) do
|
91
90
|
manifest = load_manifest(name, version)
|
92
91
|
port = `port assign #{env}.#{manifest.port}`.strip
|
93
|
-
process_container(name,version,port,env,manifest)
|
92
|
+
process_container(name, version, port, env, manifest)
|
94
93
|
end
|
95
94
|
end
|
96
95
|
|
@@ -131,7 +130,6 @@ module Harbr
|
|
131
130
|
end
|
132
131
|
|
133
132
|
def process_container(name, version, port, env, manifest)
|
134
|
-
|
135
133
|
version_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
136
134
|
|
137
135
|
bundle_install_if_needed(version_path)
|
@@ -140,21 +138,18 @@ module Harbr
|
|
140
138
|
link_directories(name, version, env)
|
141
139
|
sync_live_data_if_next(name) if env == "next"
|
142
140
|
|
143
|
-
containers = collate_containers("#{name}", "#{manifest.host}", port,manifest.host_aliases) if env == "current"
|
144
|
-
containers = collate_containers("#{env}.#{name}", "#{env}.#{manifest.host}", port,manifest.host_aliases&.map{|host| "#{env}.#{host}"
|
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"
|
145
143
|
|
146
144
|
create_traefik_config(containers)
|
147
145
|
|
148
146
|
system "sv restart #{env}.#{name}" if env == "next"
|
149
147
|
system "sv restart #{name}" if env == "current"
|
150
148
|
|
151
|
-
|
152
|
-
|
153
149
|
puts "harbr: #{version} of #{name} in #{env} environment"
|
154
150
|
end
|
155
151
|
|
156
152
|
def bundle_install_if_needed(path)
|
157
|
-
|
158
153
|
check_dir_exists(path)
|
159
154
|
|
160
155
|
Dir.chdir(path) do
|
@@ -190,8 +185,6 @@ module Harbr
|
|
190
185
|
`mkdir -p /var/log/harbr/#{name}`
|
191
186
|
|
192
187
|
end
|
193
|
-
|
194
|
-
|
195
188
|
end
|
196
189
|
|
197
190
|
def link_directories(name, version, env)
|
@@ -210,7 +203,6 @@ module Harbr
|
|
210
203
|
`ln -sf /var/harbr/containers/#{name}/versions/#{version} /var/harbr/containers/#{name}/current`
|
211
204
|
`ln -sf /etc/sv/harbr/#{name} /etc/service/#{name}`
|
212
205
|
end
|
213
|
-
|
214
206
|
end
|
215
207
|
|
216
208
|
def sync_live_data_if_next(name)
|
@@ -224,32 +216,32 @@ module Harbr
|
|
224
216
|
def initialize(container, port, env)
|
225
217
|
@container_name = container
|
226
218
|
@port = port
|
227
|
-
@env = env
|
219
|
+
@env = env == 'current' ? nil : env
|
228
220
|
end
|
229
221
|
|
230
222
|
def run_script
|
231
223
|
<<~SCRIPT
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
224
|
+
#!/bin/sh
|
225
|
+
exec 2>&1
|
226
|
+
cd /var/harbr/containers/#{@container_name}/#{@env}
|
227
|
+
exec ./exe/run #{@port} #{@env}
|
228
|
+
echo "started #{@container_name} on port #{@port}"
|
237
229
|
SCRIPT
|
238
230
|
end
|
239
231
|
|
240
232
|
def finish_script
|
241
233
|
<<~SCRIPT
|
242
|
-
|
243
|
-
|
244
|
-
|
234
|
+
#!/bin/sh
|
235
|
+
lsof -i :#{@port} | awk 'NR!=1 {print $2}' | xargs kill
|
236
|
+
echo "killed #{@container_name} on port #{@port}"
|
245
237
|
SCRIPT
|
246
238
|
end
|
247
239
|
|
248
240
|
def log_script
|
249
241
|
<<~SCRIPT
|
250
|
-
|
251
|
-
|
252
|
-
|
242
|
+
#!/bin/sh
|
243
|
+
echo "starting log for #{@container_name} on port #{@port}"
|
244
|
+
exec svlogd -tt /var/log/harbr/#{@container_name}/#{@env}
|
253
245
|
SCRIPT
|
254
246
|
end
|
255
247
|
end
|
data/lib/harbr/version.rb
CHANGED
data/lib/harbr.rb
CHANGED
@@ -39,15 +39,15 @@ module Harbr
|
|
39
39
|
puts "Error sending notification: #{e.message}"
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.notifiable(name, version,env)
|
42
|
+
def self.notifiable(name, version, env)
|
43
43
|
yield if block_given?
|
44
44
|
env = "live" if env == "current"
|
45
45
|
send_notification("Harbr: #{name} deployed to #{env} successfully", "<p>harbr: #{version} of #{name} deployed to #{env} successfully</p>")
|
46
46
|
rescue => e
|
47
47
|
html_content = <<~HTML
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
<p>Error: #{e.message}</p>
|
49
|
+
<p>#{e.backtrace.join("<br>")}</p>
|
50
|
+
<p>harbr: #{version} of #{env} #{name} failed to deploy</p>
|
51
51
|
HTML
|
52
52
|
|
53
53
|
send_notification("Harbr: #{name} failed to deploy", html_content)
|
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.1.
|
4
|
+
version: 0.1.81
|
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: 2024-01-
|
11
|
+
date: 2024-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: listen
|