orchestration 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/config/locales/en.yml +30 -1
- data/lib/orchestration/service_check.rb +35 -17
- data/lib/orchestration/services.rb +1 -0
- data/lib/orchestration/services/application/configuration.rb +2 -2
- data/lib/orchestration/services/application/healthcheck.rb +0 -4
- data/lib/orchestration/services/configuration_base.rb +7 -3
- data/lib/orchestration/services/database/configuration.rb +2 -2
- data/lib/orchestration/services/database/healthcheck.rb +0 -4
- data/lib/orchestration/services/healthcheck_base.rb +18 -1
- data/lib/orchestration/services/listener.rb +11 -0
- data/lib/orchestration/services/listener/configuration.rb +19 -0
- data/lib/orchestration/services/listener/healthcheck.rb +19 -0
- data/lib/orchestration/services/mongo/configuration.rb +2 -2
- data/lib/orchestration/services/mongo/healthcheck.rb +0 -4
- data/lib/orchestration/services/nginx_proxy/configuration.rb +0 -4
- data/lib/orchestration/services/nginx_proxy/healthcheck.rb +1 -5
- data/lib/orchestration/services/rabbitmq/configuration.rb +2 -2
- data/lib/orchestration/services/rabbitmq/healthcheck.rb +0 -4
- data/lib/orchestration/version.rb +1 -1
- data/lib/tasks/orchestration.rake +16 -7
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7209f425f6556b4cb2ea6747c24f69556faef24
|
4
|
+
data.tar.gz: 6b538236943c3c773221b0c6908b16e4dc89d5ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a949edc104c97a4b68520e37127ab654c75825505bfe0d8831eb0f786ce2cee75c5a900ecd5c19d0313c2bdaf89ad115632c5b5554344a974f36271439e0c8
|
7
|
+
data.tar.gz: 28ca0e8e45f4109ff081f9581d62fa5466b3dcbba648ebe6c392c4c0d3d45d1375c72e9165e72b0f845a15b9973f7b9dbb3cba8b2a636043242a8c92596585f9
|
data/.gitignore
CHANGED
data/config/locales/en.yml
CHANGED
@@ -16,7 +16,7 @@ en:
|
|
16
16
|
waiting: "Waiting for Mongo: %{config}"
|
17
17
|
ready: "Mongo is ready."
|
18
18
|
|
19
|
-
|
19
|
+
nginx-proxy:
|
20
20
|
waiting: "Waiting for Nginx proxy: %{config}"
|
21
21
|
ready: "Nginx proxy is ready."
|
22
22
|
|
@@ -24,5 +24,34 @@ en:
|
|
24
24
|
waiting: "Waiting for RabbitMQ: %{config}"
|
25
25
|
ready: "RabbitMQ is ready."
|
26
26
|
|
27
|
+
custom_service:
|
28
|
+
waiting: "Waiting for [%{service}]: %{config}"
|
29
|
+
ready: "[%{service}] is ready."
|
30
|
+
|
27
31
|
docker:
|
28
32
|
username_request: "Enter your Docker registry username (used for tagging images)"
|
33
|
+
|
34
|
+
rake:
|
35
|
+
docker:
|
36
|
+
username: "Output configured Docker username"
|
37
|
+
|
38
|
+
application:
|
39
|
+
wait: "Wait for database to become available"
|
40
|
+
|
41
|
+
database:
|
42
|
+
wait: "Wait for database to become available"
|
43
|
+
|
44
|
+
listener:
|
45
|
+
wait: "Wait for a locally-bound service to accept connections (pass `service=NAME`)"
|
46
|
+
|
47
|
+
mongo:
|
48
|
+
wait: "Wait for Mongo to become available"
|
49
|
+
|
50
|
+
nginx-proxy:
|
51
|
+
wait: "Wait for Nginx proxy to become available"
|
52
|
+
|
53
|
+
rabbitmq:
|
54
|
+
wait: "Wait for RabbitMQ to become available"
|
55
|
+
|
56
|
+
rabbitmq:
|
57
|
+
wait: "Initialise boilerplate for adding Docker to your application"
|
@@ -7,7 +7,7 @@ module Orchestration
|
|
7
7
|
|
8
8
|
def initialize(service, terminal, options = {})
|
9
9
|
@service = service
|
10
|
-
@service_name = service_name
|
10
|
+
@service_name = service.service_name
|
11
11
|
@terminal = terminal
|
12
12
|
@attempt_limit = options.fetch(:attempt_limit, ATTEMPT_LIMIT)
|
13
13
|
@retry_interval = options.fetch(:retry_interval, RETRY_INTERVAL)
|
@@ -42,22 +42,42 @@ module Orchestration
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def echo_waiting
|
45
|
-
@terminal.write(
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
45
|
+
@terminal.write(:waiting, service_waiting)
|
46
|
+
end
|
47
|
+
|
48
|
+
def service_waiting
|
49
|
+
I18n.t(
|
50
|
+
"orchestration.#{@service_name}.waiting",
|
51
|
+
config: friendly_config,
|
52
|
+
default: default_waiting
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_waiting
|
57
|
+
I18n.t(
|
58
|
+
'orchestration.custom_service.waiting',
|
59
|
+
config: friendly_config,
|
60
|
+
service: @service_name
|
51
61
|
)
|
52
62
|
end
|
53
63
|
|
54
64
|
def echo_ready
|
55
|
-
@terminal.write(
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
65
|
+
@terminal.write(:ready, service_ready)
|
66
|
+
end
|
67
|
+
|
68
|
+
def service_ready
|
69
|
+
I18n.t(
|
70
|
+
"orchestration.#{@service_name}.ready",
|
71
|
+
config: friendly_config,
|
72
|
+
default: default_ready
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def default_ready
|
77
|
+
I18n.t(
|
78
|
+
'orchestration.custom_service.ready',
|
79
|
+
config: friendly_config,
|
80
|
+
service: @service_name
|
61
81
|
)
|
62
82
|
end
|
63
83
|
|
@@ -72,10 +92,8 @@ module Orchestration
|
|
72
92
|
@terminal.write(:error, "[#{error.class.name}] #{error.message}")
|
73
93
|
end
|
74
94
|
|
75
|
-
def
|
76
|
-
|
77
|
-
# Orchestration::Services::RabbitMQ::Healthcheck => 'rabbitmq'
|
78
|
-
service.class.name.split('::')[-2].downcase
|
95
|
+
def friendly_config
|
96
|
+
@service.configuration.friendly_config
|
79
97
|
end
|
80
98
|
end
|
81
99
|
end
|
@@ -10,6 +10,7 @@ require 'orchestration/services/healthcheck_base'
|
|
10
10
|
|
11
11
|
require 'orchestration/services/application'
|
12
12
|
require 'orchestration/services/database'
|
13
|
+
require 'orchestration/services/listener'
|
13
14
|
require 'orchestration/services/mongo'
|
14
15
|
require 'orchestration/services/nginx_proxy'
|
15
16
|
require 'orchestration/services/rabbitmq'
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Orchestration
|
4
4
|
module Services
|
5
5
|
module ConfigurationBase
|
6
|
-
attr_reader :settings
|
6
|
+
attr_reader :settings, :service_name
|
7
7
|
|
8
8
|
def self.included(base)
|
9
9
|
base.extend(ClassMethods)
|
@@ -22,13 +22,17 @@ module Orchestration
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
+
def initialize(env, service_name = nil)
|
26
|
+
@env = env
|
27
|
+
@service_name = service_name || self.class.service_name
|
28
|
+
end
|
29
|
+
|
25
30
|
def host
|
26
31
|
'localhost'
|
27
32
|
end
|
28
33
|
|
29
34
|
def local_port
|
30
|
-
|
31
|
-
key = name == 'application' ? 'nginx-proxy' : name
|
35
|
+
key = @service_name == 'application' ? 'nginx-proxy' : @service_name
|
32
36
|
|
33
37
|
@env.docker_compose_config
|
34
38
|
.fetch('services')
|
@@ -16,7 +16,8 @@ module Orchestration
|
|
16
16
|
options.delete(:exit_on_error)
|
17
17
|
env ||= Environment.new
|
18
18
|
terminal ||= Terminal.new
|
19
|
-
|
19
|
+
name = options.delete(:service_name)
|
20
|
+
check = ServiceCheck.new(new(env, name), terminal, options)
|
20
21
|
|
21
22
|
exit 1 if !check.run && exit_on_error
|
22
23
|
end
|
@@ -33,6 +34,22 @@ module Orchestration
|
|
33
34
|
@dependencies.map { |dependency| require dependency }
|
34
35
|
end
|
35
36
|
end
|
37
|
+
|
38
|
+
def initialize(env, service_name = nil)
|
39
|
+
@configuration = configuration_class.new(env, service_name)
|
40
|
+
end
|
41
|
+
|
42
|
+
def service_name
|
43
|
+
@configuration.service_name
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def configuration_class
|
49
|
+
# Find the relevant `Configuration` class for whatever `Healthcheck`
|
50
|
+
# class we happen to be included in.
|
51
|
+
self.class.parent.const_get(:Configuration)
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
38
55
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module Services
|
5
|
+
module Listener
|
6
|
+
class Configuration
|
7
|
+
include ConfigurationBase
|
8
|
+
|
9
|
+
def self.service_name
|
10
|
+
raise ArgumentError
|
11
|
+
end
|
12
|
+
|
13
|
+
def friendly_config
|
14
|
+
"[#{@service_name}] #{host}:#{local_port}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orchestration
|
4
|
+
module Services
|
5
|
+
module Listener
|
6
|
+
class Healthcheck
|
7
|
+
include HealthcheckBase
|
8
|
+
|
9
|
+
def connect
|
10
|
+
Net::HTTP.start('localhost', @configuration.local_port)
|
11
|
+
end
|
12
|
+
|
13
|
+
def connection_errors
|
14
|
+
[Errno::ECONNREFUSED]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -8,8 +8,8 @@ module Orchestration
|
|
8
8
|
|
9
9
|
self.service_name = 'mongo'
|
10
10
|
|
11
|
-
def initialize(env)
|
12
|
-
|
11
|
+
def initialize(env, service_name = nil)
|
12
|
+
super
|
13
13
|
@settings = nil
|
14
14
|
return unless defined?(Mongoid)
|
15
15
|
return unless File.exist?(@env.mongoid_configuration_path)
|
@@ -6,12 +6,8 @@ module Orchestration
|
|
6
6
|
class Healthcheck
|
7
7
|
include HealthcheckBase
|
8
8
|
|
9
|
-
def initialize(env)
|
10
|
-
@configuration = Configuration.new(env)
|
11
|
-
end
|
12
|
-
|
13
9
|
def connect
|
14
|
-
Net::HTTP.start('localhost',
|
10
|
+
Net::HTTP.start('localhost', @configuration.local_port)
|
15
11
|
end
|
16
12
|
|
17
13
|
def connection_errors
|
@@ -8,8 +8,8 @@ module Orchestration
|
|
8
8
|
|
9
9
|
self.service_name = 'rabbitmq'
|
10
10
|
|
11
|
-
def initialize(env)
|
12
|
-
|
11
|
+
def initialize(env, service_name = nil)
|
12
|
+
super
|
13
13
|
@settings = nil
|
14
14
|
return unless defined?(RabbitMQ)
|
15
15
|
return unless File.exist?(@env.rabbitmq_configuration_path)
|
@@ -3,48 +3,48 @@
|
|
3
3
|
require 'orchestration'
|
4
4
|
|
5
5
|
namespace :orchestration do
|
6
|
-
desc '
|
6
|
+
desc I18n.t('orchestration.rake.install')
|
7
7
|
task :install do
|
8
8
|
Orchestration::InstallGenerator.start
|
9
9
|
end
|
10
10
|
|
11
11
|
namespace :application do
|
12
|
-
desc '
|
12
|
+
desc I18n.t('orchestration.application.wait')
|
13
13
|
task :wait do
|
14
14
|
Orchestration::Services::Application::Healthcheck.start
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
namespace :database do
|
19
|
-
desc '
|
19
|
+
desc I18n.t('orchestration.database.wait')
|
20
20
|
task :wait do
|
21
21
|
Orchestration::Services::Database::Healthcheck.start
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
namespace :mongo do
|
26
|
-
desc '
|
26
|
+
desc I18n.t('orchestration.mongo.wait')
|
27
27
|
task :wait do
|
28
28
|
Orchestration::Services::Mongo::Healthcheck.start
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
namespace :nginx_proxy do
|
33
|
-
desc '
|
33
|
+
desc I18n.t('orchestration.nginx-proxy.wait')
|
34
34
|
task :wait do
|
35
35
|
Orchestration::Services::NginxProxy::Healthcheck.start
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
namespace :rabbitmq do
|
40
|
-
desc '
|
40
|
+
desc I18n.t('orchestration.rabbitmq.wait')
|
41
41
|
task :wait do
|
42
42
|
Orchestration::Services::RabbitMQ::Healthcheck.start
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
namespace :docker do
|
47
|
-
desc '
|
47
|
+
desc I18n.t('orchestration.rake.listener.wait')
|
48
48
|
task :username do
|
49
49
|
STDOUT.write(
|
50
50
|
Orchestration::Environment.new.settings.get('docker.username')
|
@@ -52,4 +52,13 @@ namespace :orchestration do
|
|
52
52
|
STDOUT.flush
|
53
53
|
end
|
54
54
|
end
|
55
|
+
|
56
|
+
namespace :listener do
|
57
|
+
desc I18n.t('orchestration.rake.listener.wait')
|
58
|
+
task :wait do
|
59
|
+
Orchestration::Services::Listener::Healthcheck.start(
|
60
|
+
nil, nil, service_name: ENV.fetch('service')
|
61
|
+
)
|
62
|
+
end
|
63
|
+
end
|
55
64
|
end
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Farrell
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -315,6 +315,9 @@ files:
|
|
315
315
|
- lib/orchestration/services/database/configuration.rb
|
316
316
|
- lib/orchestration/services/database/healthcheck.rb
|
317
317
|
- lib/orchestration/services/healthcheck_base.rb
|
318
|
+
- lib/orchestration/services/listener.rb
|
319
|
+
- lib/orchestration/services/listener/configuration.rb
|
320
|
+
- lib/orchestration/services/listener/healthcheck.rb
|
318
321
|
- lib/orchestration/services/mongo.rb
|
319
322
|
- lib/orchestration/services/mongo/configuration.rb
|
320
323
|
- lib/orchestration/services/mongo/healthcheck.rb
|