Skip to content

Commit

Permalink
When executing #stop(nil), all processes should be sent the signal
Browse files Browse the repository at this point in the history
  • Loading branch information
R. Tyler Croy committed Apr 11, 2012
1 parent e4a3215 commit 38aecff
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lib/foreman/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,14 @@ def start

def stop(name, signal='SIGTERM')
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 = running_processes.delete(pid)
Expand Down Expand Up @@ -89,18 +96,11 @@ def base_port
def terminate_gracefully
return if @terminating
@terminating = true
info "sending SIGTERM to all processes"
Timeout.timeout(5) do
running_processes.each do |pid, process|
stop(process.name)
end
stop(nil)
end
rescue Timeout::Error
info "sending SIGKILL to all processes"
running_process.each do |pid, process|
info "sending #{signal} to pid #{pid}"
stop(process.name, 'SIGKILL')
end
stop(nil, 'SIGKILL')
rescue Errno::ECHILD
end

Expand Down

0 comments on commit 38aecff

Please sign in to comment.