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

Setup signal to trap SIGINT and gracefully stop server (#1377)

This way, when you send `SIGINT` to a running a server, when running via
`rails s`, a graceful shutdown/stop will be performed.

Before this, not trapping `SIGINT` would mean that either `Rails::Server#start`
or `::Rack::Server#start` would be trapping `SIGINT` and exiting the process.
This commit is contained in:
Shayon Mukherjee 2017-08-16 08:22:38 -07:00 committed by Nate Berkopec
parent aa167772e3
commit 8903eea50a

View file

@ -398,6 +398,20 @@ module Puma
log "*** SIGTERM not implemented, signal based gracefully stopping unavailable!"
end
begin
Signal.trap "SIGINT" do
if Puma.jruby?
@status = :exit
graceful_stop
exit
end
stop
end
rescue Exception
log "*** SIGINT not implemented, signal based gracefully stopping unavailable!"
end
begin
Signal.trap "SIGHUP" do
if @runner.redirected_io?
@ -409,14 +423,6 @@ module Puma
rescue Exception
log "*** SIGHUP not implemented, signal based logs reopening unavailable!"
end
if Puma.jruby?
Signal.trap("INT") do
@status = :exit
graceful_stop
exit
end
end
end
end
end