Class: Uc::Unicorn::ReadyWait
- Inherits:
-
Object
- Object
- Uc::Unicorn::ReadyWait
- Defined in:
- lib/uc/unicorn/ready_wait.rb
Instance Attribute Summary collapse
-
#ready_wait ⇒ Object
readonly
Returns the value of attribute ready_wait.
-
#run_id ⇒ Object
Returns the value of attribute run_id.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
- #event ⇒ Object
- #id ⇒ Object
-
#initialize(server, worker, run_id: nil, ready_wait: nil) ⇒ ReadyWait
constructor
A new instance of ReadyWait.
- #mq ⇒ Object
- #queue_name ⇒ Object
- #run ⇒ Object
- #wait ⇒ Object
Methods included from Helper
#first_worker?, #last_worker?, #old_pid, #restart?
Methods included from Logger
#event_queue, event_stream, #event_stream, logger, #logger, stderr, #stderr
Constructor Details
#initialize(server, worker, run_id: nil, ready_wait: nil) ⇒ ReadyWait
Returns a new instance of ReadyWait.
17 18 19 20 21 22 |
# 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 |
Instance Attribute Details
#ready_wait ⇒ Object (readonly)
Returns the value of attribute ready_wait.
14 15 16 |
# File 'lib/uc/unicorn/ready_wait.rb', line 14 def ready_wait @ready_wait end |
#run_id ⇒ Object
Returns the value of attribute run_id.
13 14 15 |
# File 'lib/uc/unicorn/ready_wait.rb', line 13 def run_id @run_id end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
14 15 16 |
# File 'lib/uc/unicorn/ready_wait.rb', line 14 def server @server end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
14 15 16 |
# File 'lib/uc/unicorn/ready_wait.rb', line 14 def worker @worker end |
Instance Method Details
#event ⇒ Object
48 49 50 |
# File 'lib/uc/unicorn/ready_wait.rb', line 48 def event run_id ? "ready_#{run_id}" : "ready" end |
#id ⇒ Object
32 33 34 |
# File 'lib/uc/unicorn/ready_wait.rb', line 32 def id @id ||= worker.nr + 1 end |
#mq ⇒ Object
52 53 54 |
# 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 ⇒ Object
28 29 30 |
# File 'lib/uc/unicorn/ready_wait.rb', line 28 def queue_name @queue_name ||= "#{event_queue}_ready_#{worker.nr}" end |
#run ⇒ Object
24 25 26 |
# File 'lib/uc/unicorn/ready_wait.rb', line 24 def run wait if ready_wait end |
#wait ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# 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 |