orchestration 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/orchestration.rb +1 -0
- data/lib/orchestration/docker_healthcheck.rb +47 -46
- data/lib/orchestration/templates/Dockerfile.erb +2 -2
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +1 -1
- 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: a8525fb5a3f6bd07564ec80a6f2663f1ab3157f7e4ad7e3db411844e36ae42d1
|
4
|
+
data.tar.gz: 7828198b463b1e40a0f4b085efe848b742aa04dded4278df485706c358eed618
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ca10bebdc3fc34cda1491dfa694386b591c0f1122c1a2d4a1c16273a6f936cdf49aa7b97b9b91b1ab271ff41b0b881a9a736956ff5d3709c07ee42da96030ea
|
7
|
+
data.tar.gz: 6c86b19c30c5265ed9ad37af22ffab8176c88e815918a62278b2cfe82d4ec9cb4f4237f2202e88423ea1580a112058231e5f5005a4e1c5cf63cf7809e105a3d3
|
data/README.md
CHANGED
data/lib/orchestration.rb
CHANGED
@@ -22,6 +22,7 @@ require 'orchestration/file_helpers'
|
|
22
22
|
require 'orchestration/docker_compose'
|
23
23
|
require 'orchestration/environment'
|
24
24
|
require 'orchestration/errors'
|
25
|
+
require 'orchestration/docker_healthcheck'
|
25
26
|
require 'orchestration/install_generator'
|
26
27
|
require 'orchestration/railtie' if defined?(Rails)
|
27
28
|
require 'orchestration/service_check'
|
@@ -1,64 +1,65 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'net/http'
|
4
|
+
module Orchestration
|
5
|
+
class DockerHealthcheck
|
6
|
+
def self.execute
|
7
|
+
new.execute
|
8
|
+
end
|
4
9
|
|
5
|
-
|
6
|
-
|
7
|
-
new.execute
|
8
|
-
end
|
9
|
-
|
10
|
-
def execute
|
11
|
-
return_code = 1
|
10
|
+
def execute
|
11
|
+
return_code = 1
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
13
|
+
# rubocop:disable Lint/RescueException
|
14
|
+
begin
|
15
|
+
response = run
|
16
|
+
return_code = 0 if success?(response.code)
|
17
|
+
puts message(response.code)
|
18
|
+
rescue Exception => e
|
19
|
+
puts "[#{__FILE__}] ERROR: #{e.inspect}"
|
20
|
+
ensure
|
21
|
+
exit return_code
|
22
|
+
end
|
23
|
+
# rubocop:enable Lint/RescueException
|
22
24
|
end
|
23
|
-
# rubocop:enable Lint/RescueException
|
24
|
-
end
|
25
25
|
|
26
|
-
|
26
|
+
private
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
def run
|
29
|
+
client = Net::HTTP.new(
|
30
|
+
ENV.fetch('WEB_HOST', 'localhost'),
|
31
|
+
ENV.fetch('WEB_PORT', '8080').to_i
|
32
|
+
)
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
client.read_timeout = ENV.fetch('WEB_HEALTHCHECK_READ_TIMEOUT', '10').to_i
|
35
|
+
client.open_timeout = ENV.fetch('WEB_HEALTHCHECK_OPEN_TIMEOUT', '10').to_i
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
client.start do |request|
|
38
|
+
request.get(ENV.fetch('WEB_HEALTHCHECK_PATH') { '/' })
|
39
|
+
end
|
39
40
|
end
|
40
|
-
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def success?(code)
|
47
|
-
success_codes.include?(code.to_s)
|
48
|
-
end
|
42
|
+
def success_codes
|
43
|
+
ENV.fetch('WEB_HEALTHCHECK_SUCCESS_CODES', '200,202,204').split(',')
|
44
|
+
end
|
49
45
|
|
50
|
-
|
51
|
-
|
52
|
-
outcome = 'SUCCESS ✓ '
|
53
|
-
in_or_not = 'IN'
|
54
|
-
else
|
55
|
-
outcome = 'FAILURE ✘ '
|
56
|
-
in_or_not = 'NOT IN'
|
46
|
+
def success?(code)
|
47
|
+
success_codes.include?(code.to_s)
|
57
48
|
end
|
58
49
|
|
59
|
-
|
60
|
-
|
50
|
+
def message(code)
|
51
|
+
if success?(code)
|
52
|
+
outcome = 'SUCCESS ✓ '
|
53
|
+
in_or_not = 'IN'
|
54
|
+
else
|
55
|
+
outcome = 'FAILURE ✘ '
|
56
|
+
in_or_not = 'NOT IN'
|
57
|
+
end
|
61
58
|
|
62
|
-
|
59
|
+
accepted = success_codes.join(', ')
|
60
|
+
message = "#{in_or_not} [#{accepted}] : #{outcome} [#{__FILE__}]"
|
61
|
+
|
62
|
+
"# HTTP_STATUS(#{code}) #{message}"
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
@@ -20,10 +20,10 @@ COPY .build/Gemfile .build/Gemfile.lock ./
|
|
20
20
|
RUN bundle install --without development test --deployment
|
21
21
|
<% if defined?(Webpacker) %>
|
22
22
|
COPY .build/package.json .build/yarn.lock ./
|
23
|
-
RUN . /root/.bashrc
|
23
|
+
RUN . /root/.bashrc ; yarn install
|
24
24
|
<% end %>
|
25
25
|
ADD .build/context.tar .
|
26
|
-
<% if defined?(Webpacker) %>RUN . /root/.bashrc
|
26
|
+
<% if defined?(Webpacker) %>RUN . /root/.bashrc ; NODE_ENV=production RAILS_ENV=production yarn install && NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=abc123 bundle exec rake assets:precompile<% elsif Rake::Task.tasks.map(&:name).include?('assets:precompile') %>RUN NODE_ENV=production RAILS_ENV=production SECRET_KEY_BASE=abc123 bundle exec rake assets:precompile<% end %>
|
27
27
|
RUN echo "${GIT_COMMIT}" > /app/GIT_COMMIT
|
28
28
|
HEALTHCHECK --interval=<%= healthcheck['interval'] %> \
|
29
29
|
--timeout=<%= healthcheck['timeout'] %> \
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orchestration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: database_url
|