1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Shutdown gracefull on SIGTERM. Fixes #53

This commit is contained in:
Evan Phoenix 2012-04-11 11:08:46 -07:00
parent c9f616e924
commit 576bea6a7c

View file

@ -266,6 +266,12 @@ module Puma
@temp_status_path = @options[:control_path_temp]
end
def graceful_stop(server)
log " - Gracefully stopping, waiting for requests to finish"
server.stop(true)
log " - Goodbye!"
end
# Parse the options, load the rackup, start the server and wait
# for it to finish.
#
@ -412,14 +418,16 @@ module Puma
server.begin_restart
end
Signal.trap "SIGTERM" do
graceful_stop server
end
log "Use Ctrl-C to stop"
begin
server.run.join
rescue Interrupt
log " - Gracefully stopping, waiting for requests to finish"
server.stop(true)
log " - Goodbye!"
graceful_stop server
end
File.unlink @temp_status_path if @temp_status_path