Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup signal to trap SIGINT and gracefully stop server #1377

Merged
merged 1 commit into from Aug 16, 2017

Conversation

shayonj
Copy link
Contributor

@shayonj shayonj commented Jul 27, 2017

This way, when you send SIGINT to 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.

Fix for: #1362

References:

Replication of current/fixed behavior:

rails s
=> Booting Puma
=> Rails 5.1.2 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.9.1 (ruby 2.3.3-p222), codename: Private Caller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2017-07-26 19:53:48 -0700 ===
- Goodbye!
Exiting

@@ -399,6 +399,14 @@ def setup_signals
end

begin
Signal.trap "SIGINT" do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lower in this file

if Puma.jruby?
  Signal.trap("INT") do

move those two together

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants