Closed Adithya-copart closed 5 years ago
I don't use jruby. Happy to take a look at PRs, but unlikely to dig in myself.
@brandonhilkert I'm new to using jruby as well. Will try to add a PR if I can find the issue. Thanks for the quick response.
@brandonhilkert I went through the documentation and required sucker_punch before sinatra but still ran into the problem. I noticed that the exit is waiting forever here: https://github.com/brandonhilkert/sucker_punch/blob/d06ba290be4d56fbbd45d37f73c47bd441ad0224/lib/sucker_punch.rb#L54
I was able to bypass by moving the shutdown process into a new thread.
Thread.new {SuckerPunch::Queue.shutdown_all}.join
Do you have any ideas on what might be causing this or where I should be looking?
I think you'd want to dig in to the shutdown_all
function. It's pretty complex and has some atomic objects pulled from concurrent-ruby that may have different behavior on jruby. I'd started by figuring out where in that method things are blocked and that would give a better sense for what's causing it.
TL;DR: Closing this issue as it deals with JRuby signal handling.
I did RUBYOPT=-d bundle exec puma
and encountered
'Exception `SystemExit' at org/jruby/RubyKernel.java:735 - exit'
at sleep PAUSE_TIME
in the shutdown_all
method.
I commented out the sleep
statement and the exception occurred again after executing the next two lines.
I did some googling and found out that the signal handling in JRuby is different. The reason I saw a graceful shutdown after opening a pry shell is because pry traps 'SIGINT'. https://github.com/pry/pry/blob/4b0b49bcbea76c46dd67b06adff0471b318997af/lib/pry/pry_class.rb#L117-L121
@Adithya-copart Nice find! Glad you got to the bottom of it.
Also opened the same issue in Puma: https://github.com/puma/puma/issues/1675
Relates to #1382 : Using
Ctrl + C
orpumactl stop
does not shutdown puma gracefully.Gemfile:
Gemfile.lock:
test_app.rb:
config.ru
Steps to reproduce
1)
bundle install
and thenbundle exec puma
.2) Hit the URL
get '/'
to trigger the jobs.3) Use
Ctrl + C
orpumactl stop
.Expected behavior
Puma should shutdown gracefully.
Actual behavior
Puma doesn't shutdown gracefully and prints the following every time
Ctrl + C
orpumactl stop -p <pid>
is used:The following is the first two lines after
Ctrl + \
However, graceful shutdown is successful when:
get '/'
is not opened.get '/pry'
is opened followed byget '/'
.The results when using
bundler/inline
are different and the shutdown is successful.test_app_bundler_inline:
System configuration
Ruby version:
jruby 9.2.0.0 (2.5.0) 2018-05-24 81156a8 Java HotSpot(TM) 64-Bit Server VM 25.181-b13 on 1.8.0_181-b13 +jit [darwin-x86_64]
Rails version: NA Puma version:puma (3.12.0-java)
EDIT: Formatting