module Unicorn::Standby
Constants
- EXIT_SIGS
- VERSION
Public Instance Methods
join()
click to toggle source
Calls superclass method
# File lib/unicorn/standby.rb, line 13 def join @_wakeup ? super : standby end
start()
click to toggle source
Calls superclass method
# File lib/unicorn/standby.rb, line 9 def start @_wakeup ? super : self end
Private Instance Methods
bind_new_listeners!()
click to toggle source
Calls superclass method
# File lib/unicorn/standby.rb, line 23 def bind_new_listeners! super unless @_wakeup end
inherit_listeners!()
click to toggle source
Calls superclass method
# File lib/unicorn/standby.rb, line 19 def inherit_listeners! super unless @_wakeup end
kill_old_master()
click to toggle source
# File lib/unicorn/standby.rb, line 46 def kill_old_master old_pid = "#{config[:pid]}.oldbin" if File.exists?(old_pid) && pid != old_pid sig = :QUIT logger.info "Sending #{sig} signal to old unicorn master..." Process.kill(sig, File.read(old_pid).to_i) end rescue Errno::ENOENT, Errno::ESRCH end
notice_to_grandparent()
click to toggle source
# File lib/unicorn/standby.rb, line 66 def notice_to_grandparent return unless @ready_pipe begin @ready_pipe.syswrite($$.to_s) rescue => e logger.warn("grandparent died too soon?: #{e.message} (#{e.class})") end @ready_pipe = @ready_pipe.close rescue nil end
ready_standby_trap()
click to toggle source
# File lib/unicorn/standby.rb, line 56 def ready_standby_trap (unicorn_queue_sigs - EXIT_SIGS).each do |signal| Signal.trap(signal) {} end EXIT_SIGS.each do |signal| Signal.trap(signal) { standby_shutdown } end end
standby()
click to toggle source
# File lib/unicorn/standby.rb, line 27 def standby self.pid = config[:pid] proc_name 'master (standby)' kill_old_master ready_standby_trap inherit_listeners! bind_new_listeners! logger.info "standby ready" notice_to_grandparent IO.select(self.class.const_get(:LISTENERS)) turn_on end
standby_shutdown()
click to toggle source
# File lib/unicorn/standby.rb, line 83 def standby_shutdown unlink_pid_safe(pid) if pid exit 0 end
turn_on()
click to toggle source
# File lib/unicorn/standby.rb, line 77 def turn_on logger.info "standby master wake up..." @_wakeup = true start.join end
unicorn_queue_sigs()
click to toggle source
# File lib/unicorn/standby.rb, line 88 def unicorn_queue_sigs if self.class.const_defined?(:QUEUE_SIGS) self.class.const_get(:QUEUE_SIGS) else @queue_sigs || [] end end