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:
parent
c9f616e924
commit
576bea6a7c
1 changed files with 11 additions and 3 deletions
|
@ -266,6 +266,12 @@ module Puma
|
||||||
@temp_status_path = @options[:control_path_temp]
|
@temp_status_path = @options[:control_path_temp]
|
||||||
end
|
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
|
# Parse the options, load the rackup, start the server and wait
|
||||||
# for it to finish.
|
# for it to finish.
|
||||||
#
|
#
|
||||||
|
@ -412,14 +418,16 @@ module Puma
|
||||||
server.begin_restart
|
server.begin_restart
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Signal.trap "SIGTERM" do
|
||||||
|
graceful_stop server
|
||||||
|
end
|
||||||
|
|
||||||
log "Use Ctrl-C to stop"
|
log "Use Ctrl-C to stop"
|
||||||
|
|
||||||
begin
|
begin
|
||||||
server.run.join
|
server.run.join
|
||||||
rescue Interrupt
|
rescue Interrupt
|
||||||
log " - Gracefully stopping, waiting for requests to finish"
|
graceful_stop server
|
||||||
server.stop(true)
|
|
||||||
log " - Goodbye!"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
File.unlink @temp_status_path if @temp_status_path
|
File.unlink @temp_status_path if @temp_status_path
|
||||||
|
|
Loading…
Add table
Reference in a new issue