Sha256: 59623f4d79890a5faabfa6c405485260c8cc41af0d7891bf5330ae86d0b79f8c

Contents?: true

Size: 1.2 KB

Versions: 4

Compression:

Stored size: 1.2 KB

Contents

module Eye::Process::Data

  # logger tag
  def full_name
    @full_name ||= [self[:application], (self[:group] == '__default__') ? nil : self[:group], self[:name]].compact.join(':')
  end

  def status_data(debug = false)
    p_st = self_status_data(debug)

    if childs.present?
      p_st.merge(:subtree => Eye::Utils::AliveArray.new(childs.values).map{|c| c.status_data(debug) } )
    elsif self[:monitor_children] && self.up?
      p_st.merge(:subtree => [{name: '=loading childs='}])
    else
      # common state
      p_st
    end
  end

  def self_status_data(debug = false)
    h = { name: name, state: state, 
          type: (self.class == Eye::ChildProcess ? :child_process : :process), 
          resources: Eye::SystemResources.resources(pid) }

    if @states_history
      h.merge!( state_changed_at: @states_history.last[:at],
                state_reason: @states_history.last[:reason] )
    end

    h.merge!(debug: debug_data) if debug
    h.merge!(current_command: current_scheduled_command) if current_scheduled_command

    h    
  end

  def debug_data
    { queue: scheduler_actions_list, watchers: @watchers.keys }
  end

  def sub_object?(obj)
    # we not recognize childs
    false
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eye-0.2.2 lib/eye/process/data.rb
eye-0.2.1 lib/eye/process/data.rb
eye-0.2 lib/eye/process/data.rb
eye-0.1.11 lib/eye/process/data.rb