process_controller 0.0.7 → 0.0.8
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/control/version.rb +1 -1
- data/lib/control_helper.rb +21 -7
- data/lib/process_controller.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4f8282d1b6740eda4a080f6c131349a2fc38cd7
|
4
|
+
data.tar.gz: d616f99ae1d8f0734b80809bf38ee370e6ebe45f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13a6be95655ec1d751c95b68dfe58edbc04e19f5243a675bc2c4e21d0bdf56eb0a10e321bd9971ff774d9a9f47ca19b37b2c5d9554c3f0ec8ec4c03a5ff84489
|
7
|
+
data.tar.gz: 11419c027bd14c442a3741f426626dc068977df5d6211bb8a4e1bbbe1a3d6ce8909085d991cd0a1e1490eddde394ac29bc2ce48a31a945ca6314528514f13941
|
data/lib/control/version.rb
CHANGED
data/lib/control_helper.rb
CHANGED
@@ -23,6 +23,7 @@ module ControlHelper
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def get_pid_from_file(pid_filename)
|
26
|
+
return nil unless File.exists?(pid_filename)
|
26
27
|
File.open(pid_filename, &:readline).strip
|
27
28
|
end
|
28
29
|
|
@@ -95,9 +96,21 @@ module ControlHelper
|
|
95
96
|
p "error in killing process #{e.inspect}"
|
96
97
|
end
|
97
98
|
|
99
|
+
# Note , only valid for http servers
|
98
100
|
def restart_the_app!(options)
|
99
|
-
|
100
|
-
|
101
|
+
if app_not_running?(options)
|
102
|
+
start_a_new_process!(options)
|
103
|
+
else
|
104
|
+
restart_command = options.fetch(Control_P::OPTIONS_ATTRIBUTES[:restart_command])
|
105
|
+
`#{restart_command}`
|
106
|
+
sleep(5)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def app_not_running?(options)
|
111
|
+
pid_filename = options.fetch(Control_P::OPTIONS_ATTRIBUTES[:pid_filename], nil)
|
112
|
+
raise "no pid filename found in #{options}" if pid_filename.nil?
|
113
|
+
'' == `cat #{pid_filename}`
|
101
114
|
end
|
102
115
|
|
103
116
|
def kill_with_retries!(options)
|
@@ -134,16 +147,17 @@ module ControlHelper
|
|
134
147
|
|
135
148
|
#TODO add option to overwrite the file names
|
136
149
|
def print_workers_started_and_stopped(options)
|
137
|
-
|
138
|
-
|
150
|
+
print_workers_and_delete_files!('workers started', Control_P::WORKERS_STARTED_EXTENTION)
|
151
|
+
print_workers_and_delete_files!('workers closed', Control_P::WORKERS_CLOSED_EXTENTION)
|
139
152
|
end
|
140
153
|
|
141
|
-
def
|
142
|
-
p
|
154
|
+
def print_workers_and_delete_files!(type, extention)
|
155
|
+
p "#{Dir[extention].length.to_s} #{type}"
|
156
|
+
Dir.glob(extention).each { |f| File.delete(f) }
|
143
157
|
end
|
144
158
|
|
145
159
|
def http_server?(options)
|
146
|
-
true == options.fetch(OPTIONS_ATTRIBUTES[:http_server], false)
|
160
|
+
true == options.fetch(Control_P::OPTIONS_ATTRIBUTES[:http_server], false)
|
147
161
|
end
|
148
162
|
|
149
163
|
def kill_the_old_process_if_needed(options)
|
data/lib/process_controller.rb
CHANGED
@@ -10,8 +10,8 @@ class Control_P
|
|
10
10
|
start_command: 'start_command'}.with_indifferent_access
|
11
11
|
|
12
12
|
FIND_BY_OPTIONS = {app_filename: 'app_filename', port_num: 'port_num', app_name: 'app_name', pid_file: 'pid_file'}.with_indifferent_access
|
13
|
-
WORKERS_STARTED_EXTENTION = 'started'
|
14
|
-
WORKERS_CLOSED_EXTENTION = 'closed'
|
13
|
+
WORKERS_STARTED_EXTENTION = '*.started'
|
14
|
+
WORKERS_CLOSED_EXTENTION = '*.closed'
|
15
15
|
|
16
16
|
HOSTNAME = Socket.gethostname
|
17
17
|
|