Class: Eye::Group
Defined Under Namespace
Modules: Chain
Instance Attribute Summary collapse
#current_scheduled_command, #last_scheduled_at, #last_scheduled_command, #last_scheduled_reason
Instance Method Summary
collapse
included, #schedule, #schedule_history, #schedule_in, #scheduled_action, #scheduler_actions_list, #scheduler_clear_pending_list, #scheduler_freeze, #scheduler_freeze?, #scheduler_unfreeze
Constructor Details
#initialize(name, config) ⇒ Group
Returns a new instance of Group.
13
14
15
16
17
18
19
|
# File 'lib/eye/group.rb', line 13
def initialize(name, config)
@name = name
@config = config
@processes = Eye::Utils::AliveArray.new
@hidden = (name == '__default__')
debug { 'created' }
end
|
Instance Attribute Details
Returns the value of attribute config.
11
12
13
|
# File 'lib/eye/group.rb', line 11
def config
@config
end
|
Returns the value of attribute hidden.
11
12
13
|
# File 'lib/eye/group.rb', line 11
def hidden
@hidden
end
|
Returns the value of attribute name.
11
12
13
|
# File 'lib/eye/group.rb', line 11
def name
@name
end
|
#processes ⇒ Object
Returns the value of attribute processes.
11
12
13
|
# File 'lib/eye/group.rb', line 11
def processes
@processes
end
|
Instance Method Details
#add_process(process) ⇒ Object
38
39
40
|
# File 'lib/eye/group.rb', line 38
def add_process(process)
@processes << process
end
|
25
26
27
|
# File 'lib/eye/group.rb', line 25
def app_name
@config[:application]
end
|
#break_chain ⇒ Object
129
130
131
132
133
|
# File 'lib/eye/group.rb', line 129
def break_chain
info 'break chain'
scheduler_clear_pending_list
@chain_breaker = true
end
|
139
140
141
|
# File 'lib/eye/group.rb', line 139
def clear
@processes = Eye::Utils::AliveArray.new
end
|
#debug_data ⇒ Object
79
80
81
|
# File 'lib/eye/group.rb', line 79
def debug_data
{:queue => scheduler_actions_list, :chain => chain_status}
end
|
108
109
110
111
|
# File 'lib/eye/group.rb', line 108
def delete
async_schedule :delete
terminate
end
|
135
136
137
|
# File 'lib/eye/group.rb', line 135
def freeze
async_schedule :freeze
end
|
#full_name ⇒ Object
29
30
31
|
# File 'lib/eye/group.rb', line 29
def full_name
@full_name ||= "#{app_name}:#{@name}"
end
|
#logger_tag ⇒ Object
21
22
23
|
# File 'lib/eye/group.rb', line 21
def logger_tag
full_name
end
|
113
114
115
|
# File 'lib/eye/group.rb', line 113
def monitor
chain_command :monitor
end
|
#resort_processes ⇒ Object
sort processes in name order
43
44
45
|
# File 'lib/eye/group.rb', line 43
def resort_processes
@processes = @processes.sort_by(&:name)
end
|
104
105
106
|
# File 'lib/eye/group.rb', line 104
def restart
chain_command :restart
end
|
#send_command(command, *args) ⇒ Object
83
84
85
86
87
88
89
90
91
92
93
94
|
# File 'lib/eye/group.rb', line 83
def send_command(command, *args)
info "send_command: #{command}"
case command
when :delete
delete(*args)
when :break_chain
break_chain(*args)
else
schedule command, *args, Eye::Reason::User.new(command)
end
end
|
#signal(sig) ⇒ Object
121
122
123
|
# File 'lib/eye/group.rb', line 121
def signal(sig)
async_schedule :signal, sig
end
|
96
97
98
|
# File 'lib/eye/group.rb', line 96
def start
chain_command :start
end
|
#status_data(debug = false) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/eye/group.rb', line 47
def status_data(debug = false)
plist = @processes.map{|p| p.status_data(debug) }
h = { name: name, type: :group, subtree: plist }
h[:debug] = debug_data if debug
if current_scheduled_command
h.update(current_command: current_scheduled_command)
if (chain_commands = scheduler_actions_list) && chain_commands.present?
h.update(chain_commands: chain_commands)
end
if @chain_processes_current && @chain_processes_count
h.update(chain_progress: [@chain_processes_current, @chain_processes_count])
end
end
h
end
|
#status_data_short ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/eye/group.rb', line 70
def status_data_short
h = Hash.new
@processes.each do |p|
h[p.state] ||= 0
h[p.state] += 1
end
{ name: (@name == '__default__' ? 'default' : @name), type: :group, states: h }
end
|
100
101
102
|
# File 'lib/eye/group.rb', line 100
def stop
async_schedule :stop
end
|
#sub_object?(obj) ⇒ Boolean
143
144
145
|
# File 'lib/eye/group.rb', line 143
def sub_object?(obj)
@processes.include?(obj)
end
|
#unmonitor ⇒ Object
117
118
119
|
# File 'lib/eye/group.rb', line 117
def unmonitor
async_schedule :unmonitor
end
|
#update_config(cfg) ⇒ Object
33
34
35
36
|
# File 'lib/eye/group.rb', line 33
def update_config(cfg)
@config = cfg
@full_name = nil
end
|
#user_command(cmd) ⇒ Object
125
126
127
|
# File 'lib/eye/group.rb', line 125
def user_command(cmd)
async_schedule :user_command, cmd
end
|