luban 0.8.6 → 0.8.7
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/CHANGELOG.md +12 -0
- data/lib/luban/deployment/cli/application/base.rb +3 -1
- data/lib/luban/deployment/cli/application/repository.rb +1 -1
- data/lib/luban/deployment/cli/application/scm/git.rb +1 -1
- data/lib/luban/deployment/cli/command.rb +34 -6
- data/lib/luban/deployment/cli/package/base.rb +2 -0
- data/lib/luban/deployment/cli/service/base.rb +3 -1
- data/lib/luban/deployment/cli/service/controller.rb +27 -30
- data/lib/luban/deployment/parameters.rb +21 -1
- data/lib/luban/deployment/templates/envrc.erb +1 -1
- data/lib/luban/deployment/templates/unset_envrc.erb +1 -1
- data/lib/luban/deployment/version.rb +1 -1
- data/lib/luban/deployment/worker/base.rb +2 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8efefadae50e7e28a9576ead9092d2d5d951349d
|
4
|
+
data.tar.gz: e0a8a86b1f33019e2953ca640cb1c5d4121aeb18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b79a40a13f3301ff09c114d6ecc8e9e3624f43d2206bc3f1afe96efef323631d66e2972c8686d80479866f847a3d067ad01429b5db382e3d64e2719d3d5f4c0
|
7
|
+
data.tar.gz: bde512704035dfdc76240f7cf05dede43a969c87d7be891db9162d2a2cc79fffa61a4aef7de00009f511f2ee419021314a08a0397b4cf1071668e58fb5fce36c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## Version 0.8.7 (Sept 27, 2016)
|
4
|
+
|
5
|
+
Minor enhancements:
|
6
|
+
* Added option #format to specify archive file format explicitly
|
7
|
+
* Added subcommands to manage process monitor: #monitor_on, #monitor_off and #monitor_reload
|
8
|
+
* Refactored convenient methods to handle process monitor
|
9
|
+
|
10
|
+
Bug fixes:
|
11
|
+
* Fixed local variables in global context in .envrc/.unset_envrc files to void bash warnings
|
12
|
+
* Skipped md5 checksum calculation for gem packages if md5 has been generated previously
|
13
|
+
* Handled result update more appropriately
|
14
|
+
|
3
15
|
## Version 0.8.6 (Sept 23, 2016)
|
4
16
|
|
5
17
|
Bug fixes:
|
@@ -7,6 +7,7 @@ module Luban
|
|
7
7
|
include Luban::Deployment::Command::Tasks::Install
|
8
8
|
include Luban::Deployment::Command::Tasks::Deploy
|
9
9
|
include Luban::Deployment::Command::Tasks::Control
|
10
|
+
include Luban::Deployment::Command::Tasks::Monitor
|
10
11
|
include Luban::Deployment::Command::Tasks::Crontab
|
11
12
|
|
12
13
|
attr_reader :packages
|
@@ -201,7 +202,8 @@ module Luban
|
|
201
202
|
deploy_cronjobs(args: args, opts: opts)
|
202
203
|
end
|
203
204
|
|
204
|
-
Luban::Deployment::Command::Tasks::Control::Actions
|
205
|
+
(Luban::Deployment::Command::Tasks::Control::Actions |
|
206
|
+
Luban::Deployment::Command::Tasks::Monitor::Actions).each do |action|
|
205
207
|
define_method(action) do |args:, opts:|
|
206
208
|
show_app_environment
|
207
209
|
send("service_#{action}!", args: args, opts: opts)
|
@@ -196,7 +196,7 @@ module Luban
|
|
196
196
|
gem_name = File.basename(gem_file)
|
197
197
|
md5_file = "#{gem_file}.md5"
|
198
198
|
gems[gem_name] =
|
199
|
-
if file?(md5_file)
|
199
|
+
if file?(workspace_path.join(md5_file))
|
200
200
|
gems[gem_name] = capture(:cat, md5_file)
|
201
201
|
else
|
202
202
|
md5_for_file(gem_file).tap { |md5|
|
@@ -32,7 +32,7 @@ module Luban
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def release
|
35
|
-
within(clone_path) { test(git_cmd, :archive, version, "--prefix=#{release_tag}/ -o #{release_package_path}") }
|
35
|
+
within(clone_path) { test(git_cmd, :archive, version, "--format=#{release_package_extname} --prefix=#{release_tag}/ -o #{release_package_path}") }
|
36
36
|
end
|
37
37
|
|
38
38
|
def branch?
|
@@ -101,12 +101,6 @@ module Luban
|
|
101
101
|
|
102
102
|
def controllable?; true; end
|
103
103
|
|
104
|
-
def process_monitor_via(monitor, env: "uber/lubmon")
|
105
|
-
monitor = monitor.to_s.downcase
|
106
|
-
env = "#{stage}.#{env.to_s.downcase}"
|
107
|
-
process_monitor name: monitor, env: env
|
108
|
-
end
|
109
|
-
|
110
104
|
protected
|
111
105
|
|
112
106
|
def setup_control_tasks
|
@@ -142,6 +136,38 @@ module Luban
|
|
142
136
|
end
|
143
137
|
end
|
144
138
|
|
139
|
+
module Monitor
|
140
|
+
Actions = %i(monitor_on monitor_off monitor_reload)
|
141
|
+
Actions.each do |action|
|
142
|
+
define_method(action) do |args:, opts:|
|
143
|
+
raise NotImplementedError, "#{self.class.name}##{__method__} is an abstract method."
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
def monitorable?
|
148
|
+
controllable? and monitor_defined? and !monitor_itself?
|
149
|
+
end
|
150
|
+
|
151
|
+
protected
|
152
|
+
|
153
|
+
def setup_monitor_tasks
|
154
|
+
task :monitor_on do
|
155
|
+
desc "Turn on process monitor"
|
156
|
+
action! :monitor_on
|
157
|
+
end
|
158
|
+
|
159
|
+
task :monitor_off do
|
160
|
+
desc "Turn off process monitor"
|
161
|
+
action! :monitor_off
|
162
|
+
end
|
163
|
+
|
164
|
+
task :monitor_reload do
|
165
|
+
desc "Reload monitor configuration"
|
166
|
+
action! :monitor_reload
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
145
171
|
module Crontab
|
146
172
|
Actions = %i(update_cronjobs list_cronjobs)
|
147
173
|
Actions.each do |action|
|
@@ -201,6 +227,7 @@ module Luban
|
|
201
227
|
def installable?; false; end
|
202
228
|
def deployable?; false; end
|
203
229
|
def controllable?; false; end
|
230
|
+
def monitorable?; false; end
|
204
231
|
|
205
232
|
def task(cmd, **opts, &blk)
|
206
233
|
command(cmd, **opts, &blk).tap do |c|
|
@@ -344,6 +371,7 @@ module Luban
|
|
344
371
|
setup_install_tasks if installable?
|
345
372
|
setup_deploy_tasks if deployable?
|
346
373
|
setup_control_tasks if controllable?
|
374
|
+
setup_monitor_tasks if monitorable?
|
347
375
|
end
|
348
376
|
|
349
377
|
%i(install deploy control).each do |action|
|
@@ -71,6 +71,8 @@ module Luban
|
|
71
71
|
include Luban::Deployment::Parameters::Application
|
72
72
|
include Luban::Deployment::Command::Tasks::Install
|
73
73
|
|
74
|
+
def monitorable?; false; end
|
75
|
+
|
74
76
|
def find_project; parent.parent; end
|
75
77
|
def find_application(name = nil)
|
76
78
|
name.nil? ? parent : find_project.apps[name.to_sym]
|
@@ -3,6 +3,7 @@ module Luban
|
|
3
3
|
module Service
|
4
4
|
class Base < Luban::Deployment::Package::Base
|
5
5
|
include Luban::Deployment::Command::Tasks::Control
|
6
|
+
include Luban::Deployment::Command::Tasks::Monitor
|
6
7
|
|
7
8
|
def self.service_action(action, dispatch_to: nil, as: action, locally: false, &blk)
|
8
9
|
define_method(action) do |args:, opts:|
|
@@ -18,7 +19,8 @@ module Luban
|
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
21
|
-
Luban::Deployment::Command::Tasks::Control::Actions
|
22
|
+
(Luban::Deployment::Command::Tasks::Control::Actions |
|
23
|
+
Luban::Deployment::Command::Tasks::Monitor::Actions).each do |action|
|
22
24
|
service_action action, dispatch_to: :controller
|
23
25
|
end
|
24
26
|
%i(init_profile update_profile).each do |action|
|
@@ -33,18 +33,6 @@ module Luban
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def process_monitorable?
|
37
|
-
process_monitor_defined? and !process_monitor?
|
38
|
-
end
|
39
|
-
|
40
|
-
def process_monitor_defined?
|
41
|
-
!process_monitor[:name].nil?
|
42
|
-
end
|
43
|
-
|
44
|
-
def process_monitor?
|
45
|
-
env_name == process_monitor[:env]
|
46
|
-
end
|
47
|
-
|
48
36
|
def monitor_executable
|
49
37
|
@monitor_executable ||= env_path.join(process_monitor[:env], 'bin',
|
50
38
|
process_monitor[:name])
|
@@ -64,10 +52,7 @@ module Luban
|
|
64
52
|
output = start_process!
|
65
53
|
if check_until { process_started? }
|
66
54
|
update_result "Start #{service_full_name}: [OK] #{output}"
|
67
|
-
if
|
68
|
-
reload_monitor_process
|
69
|
-
monitor_process
|
70
|
-
end
|
55
|
+
monitor_process if monitorable?
|
71
56
|
else
|
72
57
|
remove_orphaned_pid_file
|
73
58
|
update_result "Start #{service_full_name}: [FAILED] #{output}",
|
@@ -81,7 +66,7 @@ module Luban
|
|
81
66
|
return
|
82
67
|
end
|
83
68
|
|
84
|
-
unmonitor_process if
|
69
|
+
unmonitor_process if monitorable?
|
85
70
|
output = stop_process! || 'OK'
|
86
71
|
if check_until { process_stopped? }
|
87
72
|
update_result "Stop #{service_full_name}: [OK] #{output}"
|
@@ -94,7 +79,7 @@ module Luban
|
|
94
79
|
|
95
80
|
def restart_process
|
96
81
|
if process_started?
|
97
|
-
unmonitor_process if
|
82
|
+
unmonitor_process if monitorable?
|
98
83
|
output = stop_process!
|
99
84
|
if check_until { process_stopped? }
|
100
85
|
remove_orphaned_pid_file
|
@@ -110,7 +95,7 @@ module Luban
|
|
110
95
|
output = start_process!
|
111
96
|
if check_until { process_started? }
|
112
97
|
update_result "Restart #{service_full_name}: [OK] #{output}"
|
113
|
-
monitor_process if
|
98
|
+
monitor_process if monitorable?
|
114
99
|
else
|
115
100
|
remove_orphaned_pid_file
|
116
101
|
update_result "Restart #{service_full_name}: [FAILED] #{output}",
|
@@ -132,7 +117,7 @@ module Luban
|
|
132
117
|
return
|
133
118
|
end
|
134
119
|
|
135
|
-
unmonitor_process if
|
120
|
+
unmonitor_process if monitorable?
|
136
121
|
output = kill_process!
|
137
122
|
if check_until { process_stopped? }
|
138
123
|
update_result "Kill #{service_full_name}: [OK] #{output}"
|
@@ -142,27 +127,39 @@ module Luban
|
|
142
127
|
remove_orphaned_pid_file
|
143
128
|
end
|
144
129
|
|
145
|
-
def
|
130
|
+
def monitor_on
|
131
|
+
monitor_process(output: :update_result)
|
132
|
+
end
|
133
|
+
|
134
|
+
def monitor_off
|
135
|
+
unmonitor_process(output: :update_result)
|
136
|
+
end
|
137
|
+
|
138
|
+
def monitor_reload
|
139
|
+
reload_monitor_process(output: :update_result)
|
140
|
+
end
|
141
|
+
|
142
|
+
def monitor_process(output: :info)
|
146
143
|
if monitor_process!
|
147
|
-
|
144
|
+
send(output, "Turned on process monitor for #{service_entry}")
|
148
145
|
else
|
149
|
-
|
146
|
+
send(output, "Failed to turn on process monitor for #{service_entry}")
|
150
147
|
end
|
151
148
|
end
|
152
149
|
|
153
|
-
def unmonitor_process
|
150
|
+
def unmonitor_process(output: :info)
|
154
151
|
if unmonitor_process!
|
155
|
-
|
152
|
+
send(output, "Turned off process monitor for #{service_entry}")
|
156
153
|
else
|
157
|
-
|
154
|
+
send(output, "Failed to turn off process monitor for #{service_entry}")
|
158
155
|
end
|
159
156
|
end
|
160
157
|
|
161
|
-
def reload_monitor_process
|
158
|
+
def reload_monitor_process(output: :info)
|
162
159
|
if reload_monitor_process!
|
163
|
-
|
160
|
+
send(output, "Reloaded process monitor for #{service_entry}")
|
164
161
|
else
|
165
|
-
|
162
|
+
send(output, "Failed to reload process monitor for #{service_entry}")
|
166
163
|
end
|
167
164
|
end
|
168
165
|
|
@@ -172,7 +169,7 @@ module Luban
|
|
172
169
|
protected
|
173
170
|
|
174
171
|
def init
|
175
|
-
load_process_monitor_commands if
|
172
|
+
load_process_monitor_commands if monitorable?
|
176
173
|
end
|
177
174
|
|
178
175
|
def load_process_monitor_commands
|
@@ -74,6 +74,14 @@ module Luban
|
|
74
74
|
parameter :ssh_options
|
75
75
|
parameter :use_sudo
|
76
76
|
|
77
|
+
def process_monitor_via(monitor, env: "uber/lubmon")
|
78
|
+
monitor = monitor.to_s.downcase
|
79
|
+
env = "#{stage}.#{env.to_s.downcase}"
|
80
|
+
process_monitor name: monitor, env: env
|
81
|
+
end
|
82
|
+
|
83
|
+
def monitor_defined?; !process_monitor.empty?; end
|
84
|
+
|
77
85
|
protected
|
78
86
|
|
79
87
|
def set_default_project_parameters
|
@@ -95,7 +103,7 @@ module Luban
|
|
95
103
|
end
|
96
104
|
|
97
105
|
def validate_project_parameters
|
98
|
-
|
106
|
+
if monitor_defined?
|
99
107
|
if process_monitor[:name].nil?
|
100
108
|
abort "Aborted! Please specify the process monitor."
|
101
109
|
end
|
@@ -113,6 +121,18 @@ module Luban
|
|
113
121
|
parameter :scm_role
|
114
122
|
parameter :logrotate_files
|
115
123
|
|
124
|
+
def env_name
|
125
|
+
@env_name ||= "#{stage}.#{project}/#{application}"
|
126
|
+
end
|
127
|
+
|
128
|
+
def monitor_itself?
|
129
|
+
env_name == process_monitor[:env]
|
130
|
+
end
|
131
|
+
|
132
|
+
def monitorable?
|
133
|
+
monitor_defined? and !monitor_itself?
|
134
|
+
end
|
135
|
+
|
116
136
|
protected
|
117
137
|
|
118
138
|
def set_default_application_parameters
|
@@ -10,7 +10,7 @@ if [ -n "${LUBAN_ROOT:+x}" ]; then
|
|
10
10
|
if [[ "$LUBAN_ROOT" == "<%= app_path %>" ]]; then
|
11
11
|
echo_line "Environment <%= env_name %> has ALREADY been activated!"
|
12
12
|
else
|
13
|
-
|
13
|
+
current_env=${LUBAN_ROOT##*env/}
|
14
14
|
echo_line "Environment $current_env is STILL active!"
|
15
15
|
echo_line "Please de-activate it first:"
|
16
16
|
echo_line "\tunset_lubenv $current_env"
|
@@ -16,7 +16,7 @@ if [ -n "${LUBAN_ROOT:+x}" ]; then
|
|
16
16
|
<%- end -%>
|
17
17
|
echo_line "Environment <%= env_name %> is de-activated!"
|
18
18
|
else
|
19
|
-
|
19
|
+
current_env=${LUBAN_ROOT##*env/}
|
20
20
|
echo_line "ACTUALLY, environment $curent_env is active!"
|
21
21
|
echo_line "Please run the following command instead to de-activate it:"
|
22
22
|
echo_line "\tunset_lubenv $current_env"
|
@@ -25,10 +25,6 @@ module Luban
|
|
25
25
|
def osx?; os_name == 'Darwin'; end
|
26
26
|
def linux?; os_name == 'Linux'; end
|
27
27
|
|
28
|
-
def env_name
|
29
|
-
@env_name ||= "#{stage}.#{project}/#{application}"
|
30
|
-
end
|
31
|
-
|
32
28
|
def target_name; task.opts.name; end
|
33
29
|
def target_full_name; "#{target_name}-#{target_version}"; end
|
34
30
|
|
@@ -71,8 +67,8 @@ module Luban
|
|
71
67
|
|
72
68
|
def update_result(message = nil, status: :succeeded, level: :info, **attrs)
|
73
69
|
task.result.tap do |r|
|
74
|
-
r.status = status
|
75
|
-
r.level = level
|
70
|
+
r.status = status unless status.nil? or !r.status.nil?
|
71
|
+
r.level = level unless level.nil? or !r.level.nil?
|
76
72
|
r.message = message unless message.nil? or !r.message.nil?
|
77
73
|
attrs.each_pair { |k, v| r.send("#{k}=", v) }
|
78
74
|
unless message.nil? or message.empty?
|
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.8.
|
4
|
+
version: 0.8.7
|
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-09-
|
11
|
+
date: 2016-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: luban-cli
|