Class: Uc::Unicorn::ReadyEvent
- Inherits:
-
Object
- Object
- Uc::Unicorn::ReadyEvent
- Defined in:
- lib/uc/unicorn/ready_event.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) ⇒ ReadyEvent
constructor
A new instance of ReadyEvent.
- #mq ⇒ Object
- #notify ⇒ Object
- #queue_name ⇒ Object
- #run ⇒ 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) ⇒ ReadyEvent
Returns a new instance of ReadyEvent.
16 17 18 19 20 21 |
# File 'lib/uc/unicorn/ready_event.rb', line 16 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.
13 14 15 |
# File 'lib/uc/unicorn/ready_event.rb', line 13 def ready_wait @ready_wait end |
#run_id ⇒ Object
Returns the value of attribute run_id.
12 13 14 |
# File 'lib/uc/unicorn/ready_event.rb', line 12 def run_id @run_id end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/uc/unicorn/ready_event.rb', line 13 def server @server end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
13 14 15 |
# File 'lib/uc/unicorn/ready_event.rb', line 13 def worker @worker end |
Instance Method Details
#event ⇒ Object
48 49 50 |
# File 'lib/uc/unicorn/ready_event.rb', line 48 def event run_id ? "ready_#{run_id}" : "ready" end |
#id ⇒ Object
35 36 37 |
# File 'lib/uc/unicorn/ready_event.rb', line 35 def id @id ||= worker.nr + 1 end |
#mq ⇒ Object
52 53 54 |
# File 'lib/uc/unicorn/ready_event.rb', line 52 def mq @mq ||= ::Uc::Mqueue.new(queue_name, max_msg: 10, msg_size: 30) end |
#notify ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/uc/unicorn/ready_event.rb', line 39 def notify mq.create msg = mq.nb_writer do |writer| writer.send event end rescue Errno::ENOENT, Errno::EAGAIN, Errno::EACCES => e event_stream.warn "ready event not sent for worker #{id}: #{e.class}" end |
#queue_name ⇒ Object
31 32 33 |
# File 'lib/uc/unicorn/ready_event.rb', line 31 def queue_name @queue_name ||= "#{event_queue}_ready_#{worker.nr + 1}" end |
#run ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/uc/unicorn/ready_event.rb', line 23 def run event_stream.info "worker #{id} ready" if not last_worker? notify if ready_wait end # event_stream.pub :fin, "server #{server_event} successful" end |