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]
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue