1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Handle SIGUSR1 and SIGUSR2 as special cases so Sidekiq API works in JRuby. Fixes #2063

This commit is contained in:
Benjamin Ortega 2014-12-10 16:42:03 -06:00
parent d0cc822550
commit 23e2a2bb84
2 changed files with 19 additions and 12 deletions

View file

@ -107,17 +107,6 @@ module Sidekiq
sss }
end
private
def print_banner
# Print logo and banner for development
if environment == 'development' && $stdout.tty?
puts "\e[#{31}m"
puts Sidekiq::CLI.banner
puts "\e[0m"
end
end
def handle_signal(sig)
Sidekiq.logger.debug "Got #{sig} signal"
case sig
@ -149,6 +138,17 @@ module Sidekiq
end
end
private
def print_banner
# Print logo and banner for development
if environment == 'development' && $stdout.tty?
puts "\e[#{31}m"
puts Sidekiq::CLI.banner
puts "\e[0m"
end
end
def load_celluloid
raise "Celluloid cannot be required until here, or it will break Sidekiq's daemonization" if defined?(::Celluloid) && options[:daemon]

View file

@ -21,6 +21,7 @@ module Sidekiq
attr_accessor :fetcher
SPIN_TIME_FOR_GRACEFUL_SHUTDOWN = 1
JVM_RESERVED_SIGNALS = ['USR1', 'USR2'] # Don't Process#kill if we get these signals via the API
def initialize(condvar, options={})
logger.debug { options.inspect }
@ -159,7 +160,13 @@ module Sidekiq
end
end
::Process.kill(msg, $$) if msg
return unless msg
if JVM_RESERVED_SIGNALS.include?(msg)
Sidekiq::CLI.instance.handle_signal(msg)
else
::Process.kill(msg, $$)
end
rescue => e
# ignore all redis/network issues
logger.error("heartbeat: #{e.message}")