harbr 0.1.48 → 0.1.50
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exe/harbr +8 -15
- data/lib/harbr/job.rb +19 -11
- 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: 2194f76f6826ebac55719cf284659c5df90236fc883e654a863465506233f6b1
|
4
|
+
data.tar.gz: 656cc2ccb446abf757b301ea6533a2b47c8f36e2fb31a0d9c97d35acefd4c063
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06b2f41d6c688caf22f5c8b91dfadbc1d8116b6d12b99b117ed6069e6896cb9779938d3d5884fc5434433473ba446c0021c8868a85e14644a5e4c90ffa8ee71e
|
7
|
+
data.tar.gz: 44b75738862cec2529b340c83cc77b02ef05cc508365222e8d11d06057b7432e4c06e6cc39634f8e86f0c300f8422538efcf770cc433bf7c60bbbeeb38b1c85f
|
data/exe/harbr
CHANGED
@@ -83,13 +83,8 @@ class HarbrCLI < Thor
|
|
83
83
|
|
84
84
|
def run_jobs(container, version)
|
85
85
|
puts "Running tasks for container: #{container}, version: #{version}"
|
86
|
-
|
87
|
-
|
88
|
-
puts "deploy current version #{version} of #{container}"
|
89
|
-
else
|
90
|
-
Harbr::Job.perform_async(container, version, "next")
|
91
|
-
puts "deploy next version #{version} of #{container}"
|
92
|
-
end
|
86
|
+
Harbr::Job.perform_async(container, version, "next")
|
87
|
+
puts "deploy next version #{version} of #{container}"
|
93
88
|
end
|
94
89
|
|
95
90
|
def create_traefik_config(containers)
|
@@ -192,17 +187,15 @@ class HarbrCLI < Thor
|
|
192
187
|
|
193
188
|
desc "deploy", "deploy a container to production"
|
194
189
|
def deploy(name)
|
190
|
+
|
195
191
|
Dir.chdir("/var/harbr/containers/#{name}/") do
|
196
|
-
/(?:. * -> (?:.*))/ =~ `ls -l /var/harbr/containers/#{name}/current`
|
197
|
-
|
198
|
-
`rm -r rollback`
|
199
|
-
`ln -sf #{$2} rollback`
|
200
|
-
|
201
192
|
/(?:. * -> (?:.*))/ =~ `ls -l /var/harbr/containers/#{name}/next`
|
202
|
-
|
203
|
-
`ln -sf #{$2} current`
|
204
|
-
`sv restart #{name}`
|
193
|
+
version = $2
|
205
194
|
end
|
195
|
+
|
196
|
+
Harbr::Job.perform_async(name, version, "current")
|
197
|
+
puts "deploy current version #{version} of #{container}"
|
198
|
+
|
206
199
|
end
|
207
200
|
|
208
201
|
desc "rollback", "rollback last deploy"
|
data/lib/harbr/job.rb
CHANGED
@@ -58,12 +58,17 @@ module Harbr
|
|
58
58
|
containers.all
|
59
59
|
end
|
60
60
|
|
61
|
+
|
61
62
|
def write_to_file(path, contents)
|
63
|
+
dirname = File.dirname(path)
|
64
|
+
FileUtils.mkdir_p(dirname) unless File.directory?(dirname)
|
65
|
+
|
62
66
|
File.write(path, contents)
|
63
67
|
end
|
64
68
|
|
65
|
-
def load_manifest(
|
66
|
-
manifest_path = "/var/harbr/containers/#{
|
69
|
+
def load_manifest(name, version)
|
70
|
+
manifest_path = "/var/harbr/containers/#{name}/versions/#{version}/config/manifest.yml"
|
71
|
+
check_file_exists(manifest_path)
|
67
72
|
raise "Manifest not found at #{manifest_path}" unless File.exist?(manifest_path)
|
68
73
|
|
69
74
|
manifest_data = YAML.load_file(manifest_path)
|
@@ -72,23 +77,23 @@ module Harbr
|
|
72
77
|
|
73
78
|
def perform(name, version, env)
|
74
79
|
Harbr.notifiable(name, version) do
|
75
|
-
version_path = "/var/harbr/containers/#{name}/versions/#{version}"
|
76
|
-
check_dir_exists(version_path)
|
77
|
-
|
78
80
|
manifest = load_manifest(name, version)
|
79
81
|
port = `port assign #{env}.#{manifest.port}`.strip
|
80
|
-
|
81
|
-
process_container(name, version, port, env, manifest)
|
82
|
+
process_container(name,version,port,env,manifest)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
86
|
private
|
86
87
|
|
87
|
-
def
|
88
|
+
def check_file_exists(path)
|
88
89
|
sleep_times = [1, 3, 5, 8, 23]
|
89
90
|
begin
|
90
91
|
sleep_times.each do |time|
|
91
|
-
|
92
|
+
puts "checking #{path}...."
|
93
|
+
if File.exist?(path)
|
94
|
+
puts "found #{path}"
|
95
|
+
return
|
96
|
+
end
|
92
97
|
sleep(time)
|
93
98
|
end
|
94
99
|
raise "Directory not found: #{path}"
|
@@ -112,6 +117,11 @@ module Harbr
|
|
112
117
|
|
113
118
|
containers = collate_containers("#{env}.#{name}", "#{env}.#{manifest.host}", port)
|
114
119
|
create_traefik_config(containers)
|
120
|
+
|
121
|
+
system "sv start #{env}.#{name}" if env == "next"
|
122
|
+
system "sv start #{name}" if env == "current"
|
123
|
+
|
124
|
+
|
115
125
|
puts "harbr: #{version} of #{name} in #{env} environment"
|
116
126
|
end
|
117
127
|
|
@@ -130,12 +140,10 @@ module Harbr
|
|
130
140
|
log_script = Runit::Script.new(name, port, env).log_script
|
131
141
|
|
132
142
|
write_to_file "/etc/sv/harbr/#{name}/#{env}/run", run_script
|
133
|
-
write_to_file "/etc/sv/harbr/#{name}/#{env}/finish", finish_script
|
134
143
|
write_to_file "/etc/sv/harbr/#{name}/#{env}/log/run", log_script
|
135
144
|
|
136
145
|
`chmod +x /etc/sv/harbr/#{name}/#{env}/run`
|
137
146
|
`chmod +x /etc/sv/harbr/#{name}/#{env}/log/run`
|
138
|
-
`chmod +x /etc/sv/harbr/#{name}/#{env}/finish`
|
139
147
|
end
|
140
148
|
|
141
149
|
def link_directories(name, version, env)
|
data/lib/harbr/version.rb
CHANGED