luban 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b76fee1999addcf718abd92f2c2f49ad36e0bc01
4
- data.tar.gz: 21654c1dac641251e5dfcf7dbd643dd4b474f683
3
+ metadata.gz: 6ffbf682bcf4d234a72678f0cb42de7486a30c22
4
+ data.tar.gz: ff76e0eb5c9d74a9a0dec9f459d9befaeee0ea8d
5
5
  SHA512:
6
- metadata.gz: c7bc4215dd7b267c2910448510f93990b2d01f3d07466e06bbd07ab1fd6c5856ea15be2443ac4033c311b1f791c8e6c7284dcfd340ab877add02cb2e8dd9b429
7
- data.tar.gz: ae7e62c0cafce61eca81d3b041014c65e18550cdaca7f0800a52d0c3568c8fde901579f52895adffae1b3e696e085447ff4e5827517d7130f29d6d0194a6dd80
6
+ metadata.gz: 0d647cb328fe109f246babb23010fd1c464f652209090d5493bf07778bcfaaa74efd548ef3644147e2776198cae0b9f7c20fa1effc9fda11845ae9d3e4966306
7
+ data.tar.gz: 57de317541a53583c89e172db9b3a12e01f6e69f882319a067fb278e527e043bf305bfa76d39ea9465713dd8cf80899f64c262d0e1448fc33f7af349cc6ec4ae
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.8.1 (Sept 20, 2016)
4
+
5
+ Minor enhancements:
6
+ * Refactored process monitor commands
7
+
8
+ Bug fixes:
9
+ * Fixed a typo in output redirection for /dev/null
10
+
3
11
  ## Version 0.8.0 (Sept 19, 2016)
4
12
 
5
13
  # New features:
@@ -103,8 +103,9 @@ module Luban
103
103
 
104
104
  def process_monitor_via(monitor, env: "uber/lubmon")
105
105
  monitor = monitor.to_s.downcase
106
- env = env.to_s.downcase
107
- process_monitor name: monitor, env: env
106
+ env = "#{stage}.#{env.to_s.downcase}"
107
+ process_monitor name: monitor, env: env,
108
+ service_entry: "#{env.gsub('/', '.')}.#{monitor}"
108
109
  end
109
110
 
110
111
  protected
@@ -33,20 +33,12 @@ module Luban
33
33
  end
34
34
  end
35
35
 
36
- def monitor_executable
37
- @monitor_executable ||= env_path.join("#{stage}.#{process_monitor[:env]}", 'bin', process_monitor[:name])
38
- end
39
-
40
- def monitor_command
41
- @monitor_command ||= shell_command("#{monitor_executable} monitor #{service_entry}")
36
+ def process_monitor?
37
+ service_entry == process_monitor[:service_entry]
42
38
  end
43
39
 
44
- def unmonitor_command
45
- @unmonitor_command ||= shell_command("#{monitor_executable} unmonitor #{service_entry}")
46
- end
47
-
48
- def reload_monitor_command
49
- @reload_monitor_command ||= shell_command("#{monitor_executable} reload")
40
+ def monitor_executable
41
+ @monitor_executable ||= env_path.join(process_monitor[:env], 'bin', process_monitor[:name])
50
42
  end
51
43
 
52
44
  def start_process
@@ -58,7 +50,7 @@ module Luban
58
50
  output = start_process!
59
51
  if check_until { process_started? }
60
52
  update_result "Start #{service_full_name}: [OK] #{output}"
61
- monitor_process
53
+ monitor_process unless process_monitor?
62
54
  else
63
55
  remove_orphaned_pid_file
64
56
  update_result "Start #{service_full_name}: [FAILED] #{output}",
@@ -72,7 +64,7 @@ module Luban
72
64
  return
73
65
  end
74
66
 
75
- unmonitor_process
67
+ unmonitor_process unless process_monitor?
76
68
  output = stop_process! || 'OK'
77
69
  if check_until { process_stopped? }
78
70
  update_result "Stop #{service_full_name}: [OK] #{output}"
@@ -85,7 +77,7 @@ module Luban
85
77
 
86
78
  def restart_process
87
79
  if process_started?
88
- unmonitor_process
80
+ unmonitor_process unless process_monitor?
89
81
  output = stop_process!
90
82
  if check_until { process_stopped? }
91
83
  remove_orphaned_pid_file
@@ -101,7 +93,7 @@ module Luban
101
93
  output = start_process!
102
94
  if check_until { process_started? }
103
95
  update_result "Restart #{service_full_name}: [OK] #{output}"
104
- monitor_process
96
+ monitor_process unless process_monitor?
105
97
  else
106
98
  remove_orphaned_pid_file
107
99
  update_result "Restart #{service_full_name}: [FAILED] #{output}",
@@ -123,7 +115,7 @@ module Luban
123
115
  return
124
116
  end
125
117
 
126
- unmonitor_process
118
+ unmonitor_process unless process_monitor?
127
119
  output = kill_process!
128
120
  if check_until { process_stopped? }
129
121
  update_result "Kill #{service_full_name}: [OK] #{output}"
@@ -173,7 +165,20 @@ module Luban
173
165
  protected
174
166
 
175
167
  def before_start_process
176
- reload_monitor_process
168
+ reload_monitor_process unless process_monitor?
169
+ end
170
+
171
+ def init
172
+ load_process_monitor_commands
173
+ end
174
+
175
+ def load_process_monitor_commands
176
+ singleton_class.send(:prepend,
177
+ process_monitor_module.const_get("Controller::Commands::Public"))
178
+ end
179
+
180
+ def process_monitor_module
181
+ Luban::Deployment::Package::Base.package_class(process_monitor[:name])
177
182
  end
178
183
 
179
184
  def check_until(pending_seconds: default_pending_seconds,
@@ -225,11 +230,11 @@ module Luban
225
230
  end
226
231
 
227
232
  def monitor_process!
228
- test(monitor_command)
233
+ test(monitor_command(service_entry))
229
234
  end
230
235
 
231
236
  def unmonitor_process!
232
- test(unmonitor_command)
237
+ test(unmonitor_command(service_entry))
233
238
  end
234
239
 
235
240
  def reload_monitor_process!
@@ -20,7 +20,7 @@ module Luban
20
20
  when :stdout
21
21
  "2>&1"
22
22
  when nil
23
- ">> /dev/null 2>&1"
23
+ "> /dev/null 2>&1"
24
24
  when ""
25
25
  ""
26
26
  else
@@ -1,5 +1,5 @@
1
1
  module Luban
2
2
  module Deployment
3
- VERSION = "0.8.0"
3
+ VERSION = "0.8.1"
4
4
  end
5
5
  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.8.0
4
+ version: 0.8.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-09-19 00:00:00.000000000 Z
11
+ date: 2016-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban-cli