diff --git a/.travis.yml b/.travis.yml index 93e63d70..a13e9327 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,11 +3,12 @@ cache: bundler before_install: gem i bundler matrix: include: + - rvm: 2.4.0 - rvm: 2.3.3 - rvm: 2.2 - rvm: 2.1 - rvm: 2.0 - - rvm: jruby-9.1.6.0 + - rvm: jruby-9.1.7.0 jdk: oraclejdk8 env: - JRUBY_OPTS='--debug' diff --git a/lib/hutch/waiter.rb b/lib/hutch/waiter.rb index bb5bcb8d..084d3012 100644 --- a/lib/hutch/waiter.rb +++ b/lib/hutch/waiter.rb @@ -12,7 +12,9 @@ class ContinueProcessingSignals < RuntimeError end def self.supported_signals_of(list) - list.keep_if { |s| Signal.list.keys.include? s } + list.keep_if { |s| Signal.list.keys.include?(s) }.tap do |result| + result.delete('QUIT') if defined?(JRUBY_VERSION) + end end SHUTDOWN_SIGNALS = supported_signals_of(%w(QUIT TERM INT)).freeze diff --git a/spec/hutch/waiter_spec.rb b/spec/hutch/waiter_spec.rb index 38d1dfab..701e8b48 100644 --- a/spec/hutch/waiter_spec.rb +++ b/spec/hutch/waiter_spec.rb @@ -12,25 +12,39 @@ def start_kill_thread(signal) end end - described_class::SHUTDOWN_SIGNALS.each do |signal| - # JRuby does not support QUIT: - # The signal QUIT is in use by the JVM and will not work correctly on this platform - next if signal == 'QUIT' && defined?(JRUBY_VERSION) - - context "a #{signal} signal is received" do - it "logs that hutch is stopping" do - expect(Hutch::Logging.logger).to receive(:info) - .with("caught SIG#{signal}, stopping hutch...") - - start_kill_thread(signal) - described_class.wait_until_signaled - end + context 'a QUIT signal is received', if: RSpec::Support::Ruby.mri? do + it 'logs that hutch is stopping' do + expect(Hutch::Logging.logger).to receive(:info) + .with('caught SIGQUIT, stopping hutch...') + + start_kill_thread('QUIT') + described_class.wait_until_signaled + end + end + + context 'a TERM signal is received' do + it 'logs that hutch is stopping' do + expect(Hutch::Logging.logger).to receive(:info) + .with('caught SIGTERM, stopping hutch...') + + start_kill_thread('TERM') + described_class.wait_until_signaled + end + end + + context 'a INT signal is received' do + it 'logs that hutch is stopping' do + expect(Hutch::Logging.logger).to receive(:info) + .with('caught SIGINT, stopping hutch...') + + start_kill_thread('INT') + described_class.wait_until_signaled end end end describe described_class::SHUTDOWN_SIGNALS do - it "includes only things in Signal.list.keys" do + it 'includes only things in Signal.list.keys' do expect(described_class).to eq(described_class & Signal.list.keys) end end