tomo 1.22.0 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/tomo/cli/deploy_options.rb +1 -0
- data/lib/tomo/cli/project_options.rb +1 -1
- data/lib/tomo/configuration/dsl/config_file.rb +2 -2
- data/lib/tomo/configuration/environment.rb +6 -1
- data/lib/tomo/configuration/unknown_environment_error.rb +4 -2
- data/lib/tomo/configuration.rb +11 -4
- data/lib/tomo/error.rb +1 -1
- data/lib/tomo/plugin/puma/tasks.rb +5 -2
- data/lib/tomo/plugin/rbenv/tasks.rb +11 -1
- data/lib/tomo/plugin/rbenv.rb +2 -1
- data/lib/tomo/runtime/execution_plan.rb +1 -1
- data/lib/tomo/testing/systemctl.rb +3 -3
- data/lib/tomo/version.rb +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: a2e5e093589de77525a3e23c89ade9506ab805e6714185f223b517c855e9833f
|
|
4
|
+
data.tar.gz: '0162796e298153c9d102c49806f9e14e13a7a0b163b520ce7044c4ce2eaa3942'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: de7fcac2ea42c90e56a7517527a55c451c78fe7b681f833c2e42ea25a9002b64c439efbaf97d202931ea63aba73a4db4a18746e51f077b2add9fdfafbe406679
|
|
7
|
+
data.tar.gz: a8e0fa50d90ab152f06ffcac8e56a30411e643c7a6f871a07967e4fe0e395312648bb4aa97885f9f53136e677a89aa5e4aeec59d4c98f6b4255f2d355ec7531b
|
|
@@ -13,7 +13,7 @@ module Tomo
|
|
|
13
13
|
|
|
14
14
|
def configure_runtime(options, strict: true)
|
|
15
15
|
config = load_configuration(options)
|
|
16
|
-
env = options[:environment]
|
|
16
|
+
env = options[:environment] || config.default_environment_name
|
|
17
17
|
env = config.environments.keys.first if env.nil? && !strict
|
|
18
18
|
config = config.for_environment(env)
|
|
19
19
|
config.settings.merge!(settings_from_env)
|
|
@@ -20,8 +20,8 @@ module Tomo
|
|
|
20
20
|
self
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def environment(name, &)
|
|
24
|
-
environment = @config.environments[name.to_s] ||= Environment.new
|
|
23
|
+
def environment(name, default: false, &)
|
|
24
|
+
environment = @config.environments[name.to_s] ||= Environment.new(default:)
|
|
25
25
|
EnvironmentBlock.new(environment).instance_eval(&)
|
|
26
26
|
self
|
|
27
27
|
end
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module Tomo
|
|
4
4
|
class Configuration
|
|
5
5
|
class UnknownEnvironmentError < Tomo::Error
|
|
6
|
-
attr_accessor :name, :known_environments
|
|
6
|
+
attr_accessor :name, :known_environments, :default_environment
|
|
7
7
|
|
|
8
8
|
def to_console
|
|
9
9
|
known_environments.empty? ? no_envs : wrong_envs
|
|
@@ -27,7 +27,9 @@ module Tomo
|
|
|
27
27
|
if suggestions.any?
|
|
28
28
|
error + suggestions.to_console
|
|
29
29
|
else
|
|
30
|
-
envs = known_environments.map
|
|
30
|
+
envs = known_environments.map do |env|
|
|
31
|
+
[blue(" #{env}"), env == default_environment ? gray(" (default)") : nil].compact.join
|
|
32
|
+
end
|
|
31
33
|
error + <<~ENVS
|
|
32
34
|
|
|
33
35
|
The following environments are available:
|
data/lib/tomo/configuration.rb
CHANGED
|
@@ -38,6 +38,11 @@ module Tomo
|
|
|
38
38
|
@task_filter = RoleBasedTaskFilter.new
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
+
def default_environment_name
|
|
42
|
+
default_env = environments.one? ? environments.first : environments.find { |_, env| env.default? }
|
|
43
|
+
default_env&.first
|
|
44
|
+
end
|
|
45
|
+
|
|
41
46
|
def for_environment(environment)
|
|
42
47
|
validate_environment!(environment)
|
|
43
48
|
|
|
@@ -109,12 +114,14 @@ module Tomo
|
|
|
109
114
|
settings.merge(environments[environ].settings)
|
|
110
115
|
end
|
|
111
116
|
|
|
112
|
-
def raise_no_environment_specified
|
|
113
|
-
UnspecifiedEnvironmentError.raise_with(environments: environments.keys)
|
|
114
|
-
end
|
|
117
|
+
def raise_no_environment_specified = UnspecifiedEnvironmentError.raise_with(environments: environments.keys)
|
|
115
118
|
|
|
116
119
|
def raise_unknown_environment(environ)
|
|
117
|
-
UnknownEnvironmentError.raise_with(
|
|
120
|
+
UnknownEnvironmentError.raise_with(
|
|
121
|
+
name: environ,
|
|
122
|
+
default_environment: default_environment_name,
|
|
123
|
+
known_environments: environments.keys
|
|
124
|
+
)
|
|
118
125
|
end
|
|
119
126
|
end
|
|
120
127
|
end
|
data/lib/tomo/error.rb
CHANGED
|
@@ -6,7 +6,7 @@ module Tomo
|
|
|
6
6
|
|
|
7
7
|
include Colors
|
|
8
8
|
|
|
9
|
-
def self.raise_with(message=nil, attributes)
|
|
9
|
+
def self.raise_with(message=nil, attributes) # rubocop:disable Style/OptionalArguments
|
|
10
10
|
err = new(message)
|
|
11
11
|
attributes.each { |attr, value| err.public_send(:"#{attr}=", value) }
|
|
12
12
|
raise err
|
|
@@ -4,6 +4,9 @@ module Tomo::Plugin::Puma
|
|
|
4
4
|
class Tasks < Tomo::TaskLibrary
|
|
5
5
|
SystemdUnit = Struct.new(:name, :template, :path)
|
|
6
6
|
|
|
7
|
+
# Exposed to allow override during unit tests
|
|
8
|
+
def self.polling_delay = 1
|
|
9
|
+
|
|
7
10
|
def setup_systemd # rubocop:disable Metrics/AbcSize
|
|
8
11
|
linger_must_be_enabled!
|
|
9
12
|
|
|
@@ -90,7 +93,7 @@ module Tomo::Plugin::Puma
|
|
|
90
93
|
def wait_until
|
|
91
94
|
timeout = settings[:puma_check_timeout].to_i
|
|
92
95
|
start = Time.now.to_i
|
|
93
|
-
delay =
|
|
96
|
+
delay = self.class.polling_delay
|
|
94
97
|
|
|
95
98
|
loop do
|
|
96
99
|
sleep delay
|
|
@@ -99,7 +102,7 @@ module Tomo::Plugin::Puma
|
|
|
99
102
|
elapsed = Time.now.to_i - start
|
|
100
103
|
return false if elapsed >= timeout
|
|
101
104
|
|
|
102
|
-
delay = [delay +
|
|
105
|
+
delay = [delay + self.class.polling_delay, timeout - elapsed].min
|
|
103
106
|
end
|
|
104
107
|
end
|
|
105
108
|
|
|
@@ -37,11 +37,21 @@ module Tomo::Plugin::Rbenv
|
|
|
37
37
|
|
|
38
38
|
unless ruby_installed?(ruby_version)
|
|
39
39
|
logger.info("Installing ruby #{ruby_version} -- this may take several minutes")
|
|
40
|
-
|
|
40
|
+
using_tmpdir do
|
|
41
|
+
remote.run "CFLAGS=-O3 rbenv install #{ruby_version.shellescape} --verbose"
|
|
42
|
+
end
|
|
41
43
|
end
|
|
42
44
|
remote.run "rbenv global #{ruby_version.shellescape}"
|
|
43
45
|
end
|
|
44
46
|
|
|
47
|
+
def using_tmpdir(&)
|
|
48
|
+
tmpdir = paths.rbenv_tmpdir
|
|
49
|
+
return yield if tmpdir.nil?
|
|
50
|
+
|
|
51
|
+
remote.mkdir_p(tmpdir)
|
|
52
|
+
remote.env(TMPDIR: tmpdir, &)
|
|
53
|
+
end
|
|
54
|
+
|
|
45
55
|
def ruby_installed?(version)
|
|
46
56
|
versions = remote.capture("rbenv versions", raise_on_error: false)
|
|
47
57
|
if versions.match?(/^\*?\s*#{Regexp.quote(version)}\s/)
|
data/lib/tomo/plugin/rbenv.rb
CHANGED
|
@@ -26,7 +26,7 @@ module Tomo
|
|
|
26
26
|
|
|
27
27
|
case applicable_hosts.length
|
|
28
28
|
when 1 then applicable_hosts.first.to_s
|
|
29
|
-
when 2 then applicable_hosts.
|
|
29
|
+
when 2 then applicable_hosts.join(" and ")
|
|
30
30
|
else
|
|
31
31
|
"#{applicable_hosts.first} and #{applicable_hosts.length - 1} other hosts"
|
|
32
32
|
end
|
|
@@ -120,7 +120,7 @@ class Unit
|
|
|
120
120
|
end
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
class Service < Unit
|
|
123
|
+
class Service < Unit # rubocop:disable Style/OneClassPerFile
|
|
124
124
|
def is_active # rubocop:disable Naming/PredicatePrefix
|
|
125
125
|
exit(false) unless started?
|
|
126
126
|
puts "active"
|
|
@@ -176,8 +176,8 @@ class Service < Unit
|
|
|
176
176
|
end
|
|
177
177
|
|
|
178
178
|
def with_detached_io
|
|
179
|
-
null_in = File.open(File::NULL, "r")
|
|
180
|
-
null_out = File.open(File::NULL, "w")
|
|
179
|
+
null_in = File.open(File::NULL, "r") # rubocop:disable Style/FileOpen
|
|
180
|
+
null_out = File.open(File::NULL, "w") # rubocop:disable Style/FileOpen
|
|
181
181
|
$stdin.reopen(null_in)
|
|
182
182
|
$stderr.reopen(null_out)
|
|
183
183
|
$stdout.reopen(null_out)
|
data/lib/tomo/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tomo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.23.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Matt Brictson
|
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
188
188
|
- !ruby/object:Gem::Version
|
|
189
189
|
version: '0'
|
|
190
190
|
requirements: []
|
|
191
|
-
rubygems_version: 4.0.
|
|
191
|
+
rubygems_version: 4.0.20
|
|
192
192
|
specification_version: 4
|
|
193
193
|
summary: A friendly CLI for deploying Rails apps ✨
|
|
194
194
|
test_files: []
|