Skip to content

Commit

Permalink
Setup signal to trap SIGINT and gracefully stop server
Browse files Browse the repository at this point in the history
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, lack of `SIGINT` would mean that either `Rails::Server` or
`::Rack::Server` would be trapping `SIGINT` and exiting the process.
  • Loading branch information
Shayon Mukherjee committed Jul 27, 2017
1 parent 9141613 commit b6e3982
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/puma/launcher.rb
Expand Up @@ -398,6 +398,14 @@ def setup_signals
log "*** SIGTERM not implemented, signal based gracefully stopping unavailable!"
end

begin
Signal.trap "SIGINT" do
stop
end
rescue Exception
log "*** SIGINT not implemented, signal based gracefully stopping unavailable!"
end

begin
Signal.trap "SIGHUP" do
if @runner.redirected_io?
Expand Down

0 comments on commit b6e3982

Please sign in to comment.