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
Using at_exit for graceful stop upon receiving a SIGINT in JRuby #1868
Conversation
Needs a test. Probably just an adaptation/simplification of your reproduction app. |
@nateberkopec I'm not sure how to come up with a working test. The problem is executing the following code in a irb session will block at However, if I add the same code to a file and run it, the puma process is shutting down properly on both the branches. I'm not sure what to make out from this.
|
This works inside a file, I'll see if I can integrate this into a test instead. |
Faced jruby/jruby#1050 (comment) with an approach using So, I came-up with a test that fails on master and passes in this branch but it does use |
1cae734
to
17d735c
Compare
@nateberkopec I opened jruby/jruby#5844 to understand #1868 (comment). @headius investigated the issue and added jruby/jruby#5844 (comment). This piece of code may not longer be needed in Puma. It was initially added in #1675 no longer happens when I remove this code. The puma server shutdown as expected. Lines 408 to 413 in 9fb1228
|
@Adithya-copart It looks like Evan added that code in response to this comment: #73 (comment) What do you think? I guess Ctrl-C still shuts down the JVM right? Is that what you're seeing? |
Yep, Ctrl+C is shutting down the JVM without that piece of code. Tested on my Mac and a JRuby docker container. |
Does it remove the socket still, though? I guess it must if the tests are passing. Originally that's why this code was added, ctrl-c just blew up the JVM without properly removing the socket. |
@Adithya-copart maybe the test should check to make sure the socket is removed? Sent with GitHawk |
WIP: The server shuts down properly inside the test case when the graceful_stop is executed on the signal handler thread. Fix rubocop offenses and add a test Fix rubocop offenses and add a test Prevent teardown in test_integration.rb from trying to kill an already killed server
d195ef8
to
9d025cf
Compare
Updated the test to check if the port is available after shutdown. |
See #1868 The original intent of the trap was to ensure that the socket was removed properly. It now does, so the trap is no longer necessary.
Closing in favor of #1961 |
See #1868 The original intent of the trap was to ensure that the socket was removed properly. It now does, so the trap is no longer necessary.
This resolves #1675.
Sorry about the noise in that issue but you can find a sample app here demonstrating the problem.
The
graceful_stop
is not using the same thread as theat_exit
blocks and is being run in the JVM signal handling thread in JRuby.So, the
thread.join
here is joining@thread
on the signal handler thread and I'm not sure if that is the intention.This fix will execute
graceful_stop
within theat_exit
block on the main thread.Link: jruby/jruby#5437