luban 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/luban/deployment/cli/package/worker.rb +9 -3
- data/lib/luban/deployment/cli/service/controller.rb +43 -30
- data/lib/luban/deployment/helpers/utils.rb +10 -3
- data/lib/luban/deployment/packages/bundler.rb +1 -1
- data/lib/luban/deployment/packages/git.rb +1 -1
- data/lib/luban/deployment/packages/openssl.rb +1 -1
- data/lib/luban/deployment/packages/ruby.rb +2 -2
- data/lib/luban/deployment/packages/rubygems.rb +1 -1
- data/lib/luban/deployment/templates/envrc.erb +0 -3
- data/lib/luban/deployment/templates/header.erb +4 -0
- data/lib/luban/deployment/templates/unset_envrc.erb +0 -3
- data/lib/luban/deployment/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5795337e52a2753d22609fc84702c7b7efc71e2
|
4
|
+
data.tar.gz: 09109191101bc31336b281f2909904d94a5cc78d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ccce4793c55524d64f73ffea182d7c6336305876b15b7e1cbd5e3c43f4661a5457f36e9a69ddf554f93ded4380bc32c826637929dd60ff8c2280eb8df52e5327
|
7
|
+
data.tar.gz: f5b260f3f809787821928d385184dbb2febdb914785f48ed958e47a74a04df0987959c6a476727cc3ed24e523ff1bd4b14ab9a0e959f74a38a806bd35db00b4b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## Version 0.4.3 (Jun 16, 2016)
|
4
|
+
|
5
|
+
Minor enhancements:
|
6
|
+
* Changed #default_executable to #define_executable with a better general approach
|
7
|
+
* Refactored start/stop/monitor/unmonitor into corresponding commands for better reusability
|
8
|
+
* Added convenient methods, #default_pending_seconds and # default_pending_interval
|
9
|
+
* These two methods provided a better way to customize timging for process status check
|
10
|
+
* Refactored header information into a generic header template for all erb template files
|
11
|
+
|
12
|
+
Bug fixes:
|
13
|
+
* Fixed monitor/unmonitor timing for start/stop operations
|
14
|
+
* Checked process status before killing process
|
15
|
+
|
3
16
|
## Version 0.4.2 (Jun 07, 2016)
|
4
17
|
|
5
18
|
Minor enhancements:
|
@@ -13,9 +13,15 @@ module Luban
|
|
13
13
|
Luban::Deployment::Package::Base.worker_class(worker, **opts)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
16
|
+
def define_executable(*names)
|
17
|
+
names.each do |name|
|
18
|
+
define_method("#{name}_executable") do
|
19
|
+
if instance_variable_defined?("@#{__method__}")
|
20
|
+
instance_variable_get("@#{__method__}")
|
21
|
+
else
|
22
|
+
instance_variable_set("@#{__method__}", bin_path.join(name))
|
23
|
+
end
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
end
|
@@ -26,8 +26,23 @@ module Luban
|
|
26
26
|
file?(pid_file_path, "-s") # file is NOT zero size
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
%i(process_pattern start_command stop_command).each do |m|
|
30
|
+
define_method(m) do
|
31
|
+
raise NotImplementedError, "#{self.class.name}##{__method__} is an abstract method."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def monitor_executable
|
36
|
+
@monitor_executable ||= env_path.join("#{stage}.#{process_monitor[:env]}").
|
37
|
+
join('bin').join(process_monitor[:name])
|
38
|
+
end
|
39
|
+
|
40
|
+
def monitor_command
|
41
|
+
@monitor_command ||= "#{monitor_executable} monitor #{service_entry}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def unmonitor_command
|
45
|
+
@unmonitor_command ||= "#{monitor_executable} unmonitor #{service_entry}"
|
31
46
|
end
|
32
47
|
|
33
48
|
def start_process
|
@@ -38,8 +53,8 @@ module Luban
|
|
38
53
|
|
39
54
|
output = start_process!
|
40
55
|
if check_until { process_started? }
|
41
|
-
monitor_process
|
42
56
|
update_result "Start #{package_full_name}: [OK] #{output}"
|
57
|
+
monitor_process
|
43
58
|
else
|
44
59
|
remove_orphaned_pid_file
|
45
60
|
update_result "Start #{package_full_name}: [FAILED] #{output}",
|
@@ -53,9 +68,9 @@ module Luban
|
|
53
68
|
return
|
54
69
|
end
|
55
70
|
|
71
|
+
unmonitor_process
|
56
72
|
output = stop_process! || 'OK'
|
57
73
|
if check_until { process_stopped? }
|
58
|
-
unmonitor_process
|
59
74
|
update_result "Stop #{package_full_name}: [OK] #{output}"
|
60
75
|
else
|
61
76
|
remove_orphaned_pid_file
|
@@ -66,10 +81,10 @@ module Luban
|
|
66
81
|
|
67
82
|
def restart_process
|
68
83
|
if process_started?
|
84
|
+
unmonitor_process
|
69
85
|
output = stop_process!
|
70
86
|
if check_until { process_stopped? }
|
71
87
|
info "Stop #{package_full_name}: [OK] #{output}"
|
72
|
-
unmonitor_process
|
73
88
|
else
|
74
89
|
remove_orphaned_pid_file
|
75
90
|
update_result "Stop #{package_full_name}: [FAILED] #{output}",
|
@@ -94,9 +109,14 @@ module Luban
|
|
94
109
|
end
|
95
110
|
|
96
111
|
def kill_process
|
112
|
+
if process_stopped?
|
113
|
+
update_result "Skipped! Already stopped #{package_full_name}", status: :skipped
|
114
|
+
return
|
115
|
+
end
|
116
|
+
|
117
|
+
unmonitor_process
|
97
118
|
output = kill_process!
|
98
119
|
if check_until { process_stopped? }
|
99
|
-
unmonitor_process
|
100
120
|
remove_orphaned_pid_file
|
101
121
|
update_result "Kill #{package_full_name}: [OK] #{output}"
|
102
122
|
else
|
@@ -128,23 +148,29 @@ module Luban
|
|
128
148
|
end
|
129
149
|
end
|
130
150
|
|
131
|
-
|
151
|
+
def default_pending_seconds; 30; end
|
152
|
+
def default_pending_interval; 1; end
|
132
153
|
|
133
|
-
|
134
|
-
define_method(m) do
|
135
|
-
raise NotImplementedError, "#{self.class.name}##{__method__} is an abstract method."
|
136
|
-
end
|
137
|
-
end
|
154
|
+
protected
|
138
155
|
|
139
|
-
def check_until(pending_seconds
|
156
|
+
def check_until(pending_seconds: default_pending_seconds,
|
157
|
+
pending_interval: default_pending_interval)
|
140
158
|
succeeded = false
|
141
|
-
pending_seconds.times do
|
142
|
-
sleep
|
159
|
+
(pending_seconds/pending_interval).times do
|
160
|
+
sleep pending_interval
|
143
161
|
break if (succeeded = yield)
|
144
162
|
end
|
145
163
|
succeeded
|
146
164
|
end
|
147
165
|
|
166
|
+
def start_process!
|
167
|
+
capture("#{start_command} 2>&1")
|
168
|
+
end
|
169
|
+
|
170
|
+
def stop_process!
|
171
|
+
capture("#{stop_command} 2>&1")
|
172
|
+
end
|
173
|
+
|
148
174
|
def check_process!
|
149
175
|
if pid_file_missing?
|
150
176
|
"#{package_full_name}: started but PID file does NOT exist - #{pid_file_path}"
|
@@ -174,24 +200,11 @@ module Luban
|
|
174
200
|
end
|
175
201
|
|
176
202
|
def monitor_process!
|
177
|
-
test(
|
203
|
+
test("#{monitor_command} 2>&1")
|
178
204
|
end
|
179
205
|
|
180
206
|
def unmonitor_process!
|
181
|
-
test(
|
182
|
-
end
|
183
|
-
|
184
|
-
def process_monitor_executable
|
185
|
-
@process_monitor_executable ||= env_path.join("#{stage}.#{process_monitor[:env]}").
|
186
|
-
join('bin').join(process_monitor[:name])
|
187
|
-
end
|
188
|
-
|
189
|
-
def process_monitor_command
|
190
|
-
@process_monitor_command ||= "#{process_monitor_executable} monitor #{service_entry}"
|
191
|
-
end
|
192
|
-
|
193
|
-
def process_unmonitor_command
|
194
|
-
@process_unmonitor_command ||= "#{process_monitor_executable} unmonitor #{service_entry}"
|
207
|
+
test("#{unmonitor_command} 2>&1")
|
195
208
|
end
|
196
209
|
end
|
197
210
|
end
|
@@ -118,14 +118,21 @@ module Luban
|
|
118
118
|
# capture("curl -s -L -I -o /dev/null -w '%{http_code}' #{url}") == '200'
|
119
119
|
end
|
120
120
|
|
121
|
-
def upload_by_template(file_to_upload:, template_file:,
|
121
|
+
def upload_by_template(file_to_upload:, template_file:,
|
122
|
+
header_file: find_template_file('header.erb'),
|
123
|
+
auto_revision: false, **opts)
|
124
|
+
content = render_template(template_file, context: binding)
|
125
|
+
|
126
|
+
revision = ''
|
122
127
|
if auto_revision
|
123
128
|
require 'digest/md5'
|
124
|
-
revision = Digest::MD5.
|
129
|
+
revision = Digest::MD5.hexdigest(content)
|
125
130
|
return if revision_match?(file_to_upload, revision)
|
126
131
|
end
|
127
132
|
|
128
|
-
|
133
|
+
header = render_template(header_file, context: binding)
|
134
|
+
|
135
|
+
upload!(StringIO.new(header + content), file_to_upload)
|
129
136
|
yield file_to_upload if block_given?
|
130
137
|
end
|
131
138
|
|
@@ -74,7 +74,7 @@ module Luban
|
|
74
74
|
task.opts.install_doc
|
75
75
|
end
|
76
76
|
|
77
|
-
|
77
|
+
define_executable 'ruby'
|
78
78
|
|
79
79
|
def gem_executable
|
80
80
|
@gem_executable ||= bin_path.join('gem')
|
@@ -121,4 +121,4 @@ module Luban
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
124
|
-
end
|
124
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: luban
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rubyist Lei
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: luban-cli
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- lib/luban/deployment/parameters.rb
|
145
145
|
- lib/luban/deployment/runner.rb
|
146
146
|
- lib/luban/deployment/templates/envrc.erb
|
147
|
+
- lib/luban/deployment/templates/header.erb
|
147
148
|
- lib/luban/deployment/templates/unset_envrc.erb
|
148
149
|
- lib/luban/deployment/version.rb
|
149
150
|
- lib/luban/deployment/worker.rb
|