Skip to content

Commit

Permalink
Handle early term in workers. Fixes #206
Browse files Browse the repository at this point in the history
  • Loading branch information
evanphx committed Mar 19, 2013
1 parent d38de8f commit 86b9bf5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lib/puma/cli.rb
Expand Up @@ -662,10 +662,20 @@ def run_cluster
rescue Exception
end

master_pid = Process.pid

begin
Signal.trap "SIGTERM" do
stop = true
write.write "!"
# The worker installs there own SIGTERM when booted.
# Until then, this is run by the worker and the worker
# should just exit if they get it.
if Process.pid != master_pid
log "Early termination of worker"
exit! 0
else
stop = true
write.write "!"
end
end
rescue Exception
end
Expand Down

0 comments on commit 86b9bf5

Please sign in to comment.