Module: Eye::Controller::Helpers

Included in:
Eye::Controller
Defined in:
lib/eye/controller/helpers.rb

Instance Method Summary collapse

Instance Method Details

#all_groupsObject



45
46
47
48
49
50
51
52
# File 'lib/eye/controller/helpers.rb', line 45

def all_groups
  groups = []
  @applications.each do |app|
    groups += app.groups.to_a
  end

  groups
end

#all_processesObject



36
37
38
39
40
41
42
43
# File 'lib/eye/controller/helpers.rb', line 36

def all_processes
  processes = []
  all_groups.each do |gr|
    processes += gr.processes.to_a
  end

  processes
end

#application_by_name(name) ⇒ Object



32
33
34
# File 'lib/eye/controller/helpers.rb', line 32

def application_by_name(name)
  @applications.detect{|c| c.name == name}
end

#cache_strObject



16
17
18
# File 'lib/eye/controller/helpers.rb', line 16

def cache_str
  all_processes.map{ |p| "#{p.full_name}=#{p.state}" } * "\n"
end

#group_by_name(name) ⇒ Object



28
29
30
# File 'lib/eye/controller/helpers.rb', line 28

def group_by_name(name)
  all_groups.detect{|c| c.name == name}
end

#process_by_full_name(name) ⇒ Object



24
25
26
# File 'lib/eye/controller/helpers.rb', line 24

def process_by_full_name(name)
  all_processes.detect{|c| c.full_name == name }
end

#process_by_name(name) ⇒ Object



20
21
22
# File 'lib/eye/controller/helpers.rb', line 20

def process_by_name(name)
  all_processes.detect{|c| c.name == name}
end

#save_cacheObject



10
11
12
13
14
# File 'lib/eye/controller/helpers.rb', line 10

def save_cache
  File.open(Eye::Local.cache_path, 'w') { |f| f.write(cache_str) }
rescue => ex
  log_ex(ex)
end

#set_proc_lineObject



3
4
5
6
7
8
# File 'lib/eye/controller/helpers.rb', line 3

def set_proc_line
  str = Eye::PROCLINE
  str += " (#{@applications.map(&:name) * ', '})" if @applications.present?
  str += " [#{ENV['EYE_V']}]" if ENV['EYE_V']
  $0 = str
end

#short_treeObject

=> {‘group_name’ => {‘process_name’ => ‘pid_file’}}



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/eye/controller/helpers.rb', line 55

def short_tree
  res = {}
  @applications.each do |app|
    res2 = {}

    app.groups.each do |group|
      res3 = {}

      group.processes.each do |process|
        res3[process.name] = process[:pid_file_ex]
      end

      res2[group.name] = res3
    end

    res[app.name] = res2
  end

  res
end