Class: Ruote::Worker::Info

Inherits:
Object
  • Object
show all
Defined in:
lib/ruote/worker.rb

Overview

Gathering stats about this worker.

Those stats can then be obtained via Dashboard#worker_info (Engine#worker_info).

Instance Method Summary collapse

Constructor Details

#initialize(worker) ⇒ Info

Returns a new instance of Info.



605
606
607
608
609
610
611
612
613
614
615
# File 'lib/ruote/worker.rb', line 605

def initialize(worker)

  @worker = worker
  @ip = Ruote.local_ip
  @hostname = Socket.gethostname
  @system = `uname -a`.strip rescue nil

  @since = Time.now
  @msgs = []
  @last_save = Time.now - 2 * 60
end

Instance Method Details

#<<(msg) ⇒ Object



617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
# File 'lib/ruote/worker.rb', line 617

def <<(msg)

  if msg['put_at'].nil?
    puts '-' * 80
    puts "msg missing 'put_at':"
    pp msg
    puts '-' * 80
  end

  @msgs << {
    'processed_at' => Ruote.now_to_utc_s,
    'wait_time' => Time.now - Time.parse(msg['put_at'])
    #'action' => msg['action']
  }

  save if Time.now > @last_save + 60
end