Sha256: 0136797361071360b6cc505754d50209665463ec0340496fcff3d5105552c370

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

module Eye::Process::Data

  def logger_tag
    full_name
  end

  def app_name
    self[:application]
  end

  def group_name
    (self[:group] == '__default__') ? nil : self[:group]
  end

  def full_name
    @full_name ||= [app_name, group_name, 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_state_changed_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)
    return false if self.class == Eye::ChildProcess
    self.childs.each { |_, child| return true if child == obj }
    false
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
reel-eye-0.5 lib/eye/process/data.rb
eye-0.5 lib/eye/process/data.rb
eye-0.4.2 lib/eye/process/data.rb
reel-eye-0.4.1 lib/eye/process/data.rb
eye-0.4.1 lib/eye/process/data.rb
reel-eye-0.4 lib/eye/process/data.rb
eye-0.4 lib/eye/process/data.rb