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



617
618
619
620
621
622
623
624
625
626
627
# File 'lib/ruote/worker.rb', line 617

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



629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
# File 'lib/ruote/worker.rb', line 629

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