Module: Eye::Process::Data

Included in:
ChildProcess, Eye::Process
Defined in:
lib/eye/process/data.rb

Instance Method Summary collapse

Instance Method Details

#app_nameObject



7
8
9
# File 'lib/eye/process/data.rb', line 7

def app_name
  self[:application]
end

#debug_dataObject



48
49
50
# File 'lib/eye/process/data.rb', line 48

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

#full_nameObject



15
16
17
# File 'lib/eye/process/data.rb', line 15

def full_name
  @full_name ||= [app_name, group_name, self[:name]].compact.join(':')
end

#group_nameObject



11
12
13
# File 'lib/eye/process/data.rb', line 11

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

#logger_tagObject



3
4
5
# File 'lib/eye/process/data.rb', line 3

def logger_tag
  full_name
end

#self_status_data(debug = false) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/eye/process/data.rb', line 32

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.to_i,
              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

#status_data(debug = false) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/eye/process/data.rb', line 19

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

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

#sub_object?(obj) ⇒ Boolean

Returns:

  • (Boolean)


52
53
54
55
56
# File 'lib/eye/process/data.rb', line 52

def sub_object?(obj)
  return false if self.class == Eye::ChildProcess
  self.children.each { |_, child| return true if child == obj }
  false
end