luban 0.6.0 → 0.6.1
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 +7 -0
- data/lib/luban/deployment/cli/application/base.rb +9 -6
- data/lib/luban/deployment/cli/application/controller.rb +48 -0
- data/lib/luban/deployment/cli/application/worker.rb +4 -0
- data/lib/luban/deployment/cli/command.rb +8 -3
- data/lib/luban/deployment/cli/service/controller.rb +20 -1
- data/lib/luban/deployment/helpers/utils.rb +1 -1
- data/lib/luban/deployment/version.rb +1 -1
- 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: aad609d3b76333f4673f7851c43f1d5412d36edd
|
4
|
+
data.tar.gz: 45e4da3e1f8f785320562b414f62fff7d100e048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8cc42f3e6cf39cb53af1e1ff023d4e883358e3243bafaa44666f09350b1be4e7daccfc90e27d9a8636c74a559b64d3112b26a726b66521b75e60125ffb712ddc
|
7
|
+
data.tar.gz: c687a78ff0a2f69ba6765fc821c982a4a62850bfffb081041455f6d126b40383e6d75928adb35bf043509ab55ac8c9f0791a516ac30b17b488d4879c3ebb71e8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## Version 0.6.1 (Jul 11, 2016)
|
4
|
+
|
5
|
+
New features:
|
6
|
+
* Added subcommand #process to grep and show running service/application processes
|
7
|
+
* Subcommands #version and #versions now also show the release info for application
|
8
|
+
* Used group to monitor/unmonitor service for cluster mode
|
9
|
+
|
3
10
|
## Version 0.6.0 (Jul 08, 2016)
|
4
11
|
|
5
12
|
New features:
|
@@ -115,13 +115,16 @@ module Luban
|
|
115
115
|
protected "#{action}!"
|
116
116
|
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
118
|
+
{ show_current: :controller, show_summary: :controller,
|
119
|
+
cleanup: :constructor }.each_pair do |action, worker|
|
120
|
+
alias_method "#{action}_packages!", "#{action}!"
|
121
|
+
define_method("#{action}!") do |args:, opts:|
|
122
|
+
send("#{action}_application!", args: args, opts: opts)
|
123
|
+
send("#{action}_packages!", args: args, opts: opts)
|
124
|
+
end
|
125
|
+
protected "#{action}!"
|
126
|
+
dispatch_task "#{action}_application!", to: worker, as: action
|
122
127
|
end
|
123
|
-
protected :cleanup!
|
124
|
-
dispatch_task :cleanup_application!, to: :constructor, as: :cleanup
|
125
128
|
|
126
129
|
def deploy(args:, opts:)
|
127
130
|
show_app_environment
|
@@ -3,6 +3,54 @@ module Luban
|
|
3
3
|
class Application
|
4
4
|
class Controller < Worker
|
5
5
|
include Luban::Deployment::Service::Controller::Base
|
6
|
+
|
7
|
+
def current_release?(_release_tag)
|
8
|
+
_release_tag =~ /^#{Regexp.escape(application_version)}/
|
9
|
+
end
|
10
|
+
|
11
|
+
def current_symlinked?(_release_tag)
|
12
|
+
_release_tag == release_tag
|
13
|
+
end
|
14
|
+
|
15
|
+
def release_path
|
16
|
+
@release_path ||= Pathname.new(readlink(app_path.join('app')))
|
17
|
+
end
|
18
|
+
|
19
|
+
def releases_path
|
20
|
+
@releases_path ||= release_path.dirname
|
21
|
+
end
|
22
|
+
|
23
|
+
def release_tag
|
24
|
+
@release_tag ||= release_path.basename.to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def show_current
|
28
|
+
update_result get_summary(release_tag)
|
29
|
+
end
|
30
|
+
|
31
|
+
def show_summary
|
32
|
+
update_result get_summary(*get_releases)
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_releases
|
36
|
+
capture(:ls, '-xt', releases_path).split
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def get_status(tag)
|
42
|
+
if current_symlinked?(tag)
|
43
|
+
current_release?(tag) ? " *" : "s*"
|
44
|
+
else
|
45
|
+
(current_release?(tag) and !current_release?(release_tag)) ? "c*" : " "
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_summary(*release_tags)
|
50
|
+
release_tags.inject([]) do |r, tag|
|
51
|
+
r.push "#{get_status(tag)} #{application_name}:#{tag} (published)"
|
52
|
+
end.join("\n")
|
53
|
+
end
|
6
54
|
end
|
7
55
|
end
|
8
56
|
end
|
@@ -46,12 +46,12 @@ module Luban
|
|
46
46
|
end
|
47
47
|
|
48
48
|
task :version do
|
49
|
-
desc "Show current version for required packages"
|
49
|
+
desc "Show current version for app/required packages"
|
50
50
|
action! :show_current
|
51
51
|
end
|
52
52
|
|
53
53
|
task :versions do
|
54
|
-
desc "Show package installation summary"
|
54
|
+
desc "Show app/package installation summary"
|
55
55
|
action! :show_summary
|
56
56
|
end
|
57
57
|
|
@@ -91,7 +91,7 @@ module Luban
|
|
91
91
|
|
92
92
|
module Control
|
93
93
|
Actions = %i(start_process stop_process kill_process
|
94
|
-
restart_process check_process)
|
94
|
+
restart_process check_process show_process)
|
95
95
|
Actions.each do |action|
|
96
96
|
define_method(action) do |args:, opts:|
|
97
97
|
raise NotImplementedError, "#{self.class.name}##{__method__} is an abstract method."
|
@@ -133,6 +133,11 @@ module Luban
|
|
133
133
|
desc "Check process status"
|
134
134
|
action! :check_process
|
135
135
|
end
|
136
|
+
|
137
|
+
task :process do
|
138
|
+
desc "Show running process if any"
|
139
|
+
action! :show_process
|
140
|
+
end
|
136
141
|
end
|
137
142
|
end
|
138
143
|
end
|
@@ -108,6 +108,10 @@ module Luban
|
|
108
108
|
update_result check_process!
|
109
109
|
end
|
110
110
|
|
111
|
+
def show_process
|
112
|
+
update_result show_process!
|
113
|
+
end
|
114
|
+
|
111
115
|
def kill_process
|
112
116
|
if process_stopped?
|
113
117
|
update_result "Skipped! Already stopped #{service_full_name}", status: :skipped
|
@@ -188,13 +192,20 @@ module Luban
|
|
188
192
|
end
|
189
193
|
|
190
194
|
def process_grep(pattern = process_pattern)
|
191
|
-
capture(:pgrep, "-l -f \"#{pattern}\" 2>/dev/null").split.inject({}) do |h, p|
|
195
|
+
capture(:pgrep, "-l -f \"#{pattern}\" 2>/dev/null").split("\n").inject({}) do |h, p|
|
192
196
|
pid, pname = p.split(' ', 2)
|
193
197
|
h[pid] = pname
|
194
198
|
h
|
195
199
|
end
|
196
200
|
end
|
197
201
|
|
202
|
+
def show_process!
|
203
|
+
result = process_grep.inject("") do |s, (pid, cmd)|
|
204
|
+
s += "#{pid} : #{cmd}\n"
|
205
|
+
end
|
206
|
+
result.empty? ? "No processes are found up and running." : result
|
207
|
+
end
|
208
|
+
|
198
209
|
def remove_orphaned_pid_file
|
199
210
|
rm(pid_file_path) if pid_file_orphaned?
|
200
211
|
end
|
@@ -237,6 +248,14 @@ module Luban
|
|
237
248
|
def remove_orphaned_pid_file
|
238
249
|
rm(pid_files_path) if pid_file_orphaned?
|
239
250
|
end
|
251
|
+
|
252
|
+
def monitor_command
|
253
|
+
@monitor_command ||= "#{monitor_executable} monitor -g #{service_entry}"
|
254
|
+
end
|
255
|
+
|
256
|
+
def unmonitor_command
|
257
|
+
@unmonitor_command ||= "#{monitor_executable} unmonitor -g #{service_entry}"
|
258
|
+
end
|
240
259
|
end
|
241
260
|
|
242
261
|
include Base
|
@@ -139,7 +139,7 @@ module Luban
|
|
139
139
|
def render_template(template_file, context: binding)
|
140
140
|
require 'erb'
|
141
141
|
template = File.read(template_file)
|
142
|
-
ERB.new(template, nil, '
|
142
|
+
ERB.new(template, nil, '-').result(context)
|
143
143
|
end
|
144
144
|
|
145
145
|
def revision_match?(file_to_upload, revision)
|
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.6.
|
4
|
+
version: 0.6.1
|
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-07-
|
11
|
+
date: 2016-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: luban-cli
|