When executing #stop(nil), all processes should be sent the signal
This commit is contained in:
+10
-10
@@ -44,7 +44,14 @@ class Foreman::Engine
|
|||||||
|
|
||||||
def stop(name, signal='SIGTERM')
|
def stop(name, signal='SIGTERM')
|
||||||
running_processes.each do |pid, process|
|
running_processes.each do |pid, process|
|
||||||
next unless process.name.start_with? name
|
unless name.nil?
|
||||||
|
# Comparing against process.entry.name instead of process.name to
|
||||||
|
# make sure we match the process name exactly for any/all
|
||||||
|
# concurrently running processes by this name
|
||||||
|
next unless process.entry.name == name
|
||||||
|
else
|
||||||
|
info "sending #{signal} to all processes"
|
||||||
|
end
|
||||||
|
|
||||||
process.kill signal
|
process.kill signal
|
||||||
process = running_processes.delete(pid)
|
process = running_processes.delete(pid)
|
||||||
@@ -89,18 +96,11 @@ private ######################################################################
|
|||||||
def terminate_gracefully
|
def terminate_gracefully
|
||||||
return if @terminating
|
return if @terminating
|
||||||
@terminating = true
|
@terminating = true
|
||||||
info "sending SIGTERM to all processes"
|
|
||||||
Timeout.timeout(5) do
|
Timeout.timeout(5) do
|
||||||
running_processes.each do |pid, process|
|
stop(nil)
|
||||||
stop(process.name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
rescue Timeout::Error
|
rescue Timeout::Error
|
||||||
info "sending SIGKILL to all processes"
|
stop(nil, 'SIGKILL')
|
||||||
running_process.each do |pid, process|
|
|
||||||
info "sending #{signal} to pid #{pid}"
|
|
||||||
stop(process.name, 'SIGKILL')
|
|
||||||
end
|
|
||||||
rescue Errno::ECHILD
|
rescue Errno::ECHILD
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user