perfectqueue 0.8.28 → 0.8.29
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +16 -0
- data/lib/perfectqueue/multiprocess/child_process_monitor.rb +46 -9
- data/lib/perfectqueue/version.rb +1 -1
- metadata +2 -2
data/ChangeLog
CHANGED
@@ -1,4 +1,20 @@
|
|
1
1
|
|
2
|
+
== 2014-04-02 version 0.8.29
|
3
|
+
|
4
|
+
* Updated ChildProcessMonitor to kill grandchildren to not depend on
|
5
|
+
sys-proctable gem
|
6
|
+
|
7
|
+
|
8
|
+
== 2014-03-31 version 0.8.28
|
9
|
+
|
10
|
+
* Fixed ChildProcessMonitor when heartbeat pipe is closed
|
11
|
+
|
12
|
+
|
13
|
+
== 2014-03-31 version 0.8.27
|
14
|
+
|
15
|
+
* ChildProcessMonitor kills grandchildren as well when it force kills children.
|
16
|
+
|
17
|
+
|
2
18
|
== 2014-03-27 version 0.8.26
|
3
19
|
|
4
20
|
* Added delay before sending KILL signal to worker process when
|
@@ -52,7 +52,7 @@ module PerfectQueue
|
|
52
52
|
|
53
53
|
now = Time.now.to_i
|
54
54
|
if delay == 0
|
55
|
-
|
55
|
+
kill_children(now, nil)
|
56
56
|
@kill_start_time = now
|
57
57
|
else
|
58
58
|
@kill_start_time = now + delay
|
@@ -88,7 +88,7 @@ module PerfectQueue
|
|
88
88
|
# resend signal
|
89
89
|
now = Time.now.to_i
|
90
90
|
if @last_kill_time + kill_interval <= now
|
91
|
-
|
91
|
+
kill_children(now, graceful_kill_limit)
|
92
92
|
end
|
93
93
|
|
94
94
|
return false
|
@@ -107,19 +107,56 @@ module PerfectQueue
|
|
107
107
|
end
|
108
108
|
|
109
109
|
private
|
110
|
-
def
|
110
|
+
def kill_children(now, graceful_kill_limit)
|
111
|
+
immediate = @kill_immediate || (graceful_kill_limit && @kill_start_time + graceful_kill_limit < now)
|
112
|
+
|
113
|
+
if immediate
|
114
|
+
pids = collect_child_pids(get_ppid_pids_map, [@pid], @pid)
|
115
|
+
pids.reverse_each {|pid|
|
116
|
+
kill_process(child, true)
|
117
|
+
}
|
118
|
+
else
|
119
|
+
kill_process(@pid, false)
|
120
|
+
end
|
121
|
+
|
122
|
+
@last_kill_time = now
|
123
|
+
end
|
124
|
+
|
125
|
+
def get_ppid_pids_map
|
126
|
+
ppid_pids = {} # {ppid => [pid]}
|
127
|
+
`ps -ao pid,ppid`.each_line do |line|
|
128
|
+
if m = /^\s*(\d+)\s+(\d+)\s*$/.match(line)
|
129
|
+
(ppid_pids[m[2].to_i] ||= []) << m[1].to_i
|
130
|
+
end
|
131
|
+
end
|
132
|
+
return ppid_pids
|
133
|
+
# We can ignore errors but not necessary
|
134
|
+
#rescue
|
135
|
+
# return {}
|
136
|
+
end
|
137
|
+
|
138
|
+
def collect_child_pids(ppid_pids, results, parent_pid)
|
139
|
+
if pids = ppid_pids[parent_pid]
|
140
|
+
pids.each {|pid|
|
141
|
+
results << pid
|
142
|
+
collect_child_pids(ppid_pids, results, pid)
|
143
|
+
}
|
144
|
+
end
|
145
|
+
results
|
146
|
+
end
|
147
|
+
|
148
|
+
def kill_process(pid, immediate)
|
111
149
|
begin
|
112
|
-
if
|
113
|
-
@log.debug "sending SIGKILL to pid=#{
|
114
|
-
Process.kill(:KILL,
|
150
|
+
if immediate
|
151
|
+
@log.debug "sending SIGKILL to pid=#{pid} for immediate stop"
|
152
|
+
Process.kill(:KILL, pid)
|
115
153
|
else
|
116
|
-
@log.debug "sending SIGTERM to pid=#{
|
117
|
-
Process.kill(:TERM,
|
154
|
+
@log.debug "sending SIGTERM to pid=#{pid} for graceful stop"
|
155
|
+
Process.kill(:TERM, pid)
|
118
156
|
end
|
119
157
|
rescue Errno::ESRCH, Errno::EPERM
|
120
158
|
# TODO log?
|
121
159
|
end
|
122
|
-
@last_kill_time = now
|
123
160
|
end
|
124
161
|
end
|
125
162
|
|
data/lib/perfectqueue/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: perfectqueue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.29
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|