class Uc::Unicorn::ReadyWait

Attributes

ready_wait[R]
run_id[RW]
server[R]
worker[R]

Public Class Methods

new(server, worker, run_id: nil, ready_wait: nil) click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 17
def initialize(server, worker, run_id: nil, ready_wait: nil)
  @server = server
  @worker = worker
  @run_id = run_id
  @ready_wait = ready_wait
end

Public Instance Methods

event() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 48
def event
  run_id ? "ready_#{run_id}" : "ready" 
end
id() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 32
def id
  @id ||= worker.nr + 1
end
mq() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 52
def mq
  @mq ||= ::Uc::Mqueue.new(queue_name, max_msg: 10, msg_size: 30)
end
queue_name() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 28
def queue_name
   @queue_name ||= "#{event_queue}_ready_#{worker.nr}"
end
run() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 24
def run
  wait if ready_wait
end
wait() click to toggle source
# File lib/uc/unicorn/ready_wait.rb, line 36
def wait
  if first_worker?
    event_stream.debug "no wait for worker #{worker.nr}"
    return
  end
  mq.create
  msg = mq.wait(event, ready_wait)
  event_stream.debug "ack worker ready #{worker.nr}"
rescue Errno::ENOENT, Errno::EAGAIN, Errno::EACCES, Errno::ETIMEDOUT => e
  event_stream.warn "ready wait error #{worker.nr}: #{e.class}"
end