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
#execute_proc, 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.
14
15
16
17
18
19
20
|
# File 'lib/eye/group.rb', line 14
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.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def config
@config
end
|
Returns the value of attribute hidden.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def hidden
@hidden
end
|
Returns the value of attribute name.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def name
@name
end
|
#processes ⇒ Object
Returns the value of attribute processes.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def processes
@processes
end
|
Instance Method Details
#<=>(other) ⇒ Object
150
151
152
153
154
155
156
157
158
159
160
|
# File 'lib/eye/group.rb', line 150
def <=>(other)
if hidden
1
else
if other.hidden
-1
else
name <=> other.name
end
end
end
|
#add_process(process) ⇒ Object
39
40
41
|
# File 'lib/eye/group.rb', line 39
def add_process(process)
@processes << process
end
|
26
27
28
|
# File 'lib/eye/group.rb', line 26
def app_name
@config[:application]
end
|
#break_chain ⇒ Object
131
132
133
134
135
|
# File 'lib/eye/group.rb', line 131
def break_chain
info 'break chain'
scheduler_clear_pending_list
@chain_breaker = true
end
|
#debug_data ⇒ Object
81
82
83
|
# File 'lib/eye/group.rb', line 81
def debug_data
{ queue: scheduler_actions_list, chain: chain_status }
end
|
110
111
112
113
|
# File 'lib/eye/group.rb', line 110
def delete
async_schedule :delete
terminate
end
|
137
138
139
|
# File 'lib/eye/group.rb', line 137
def freeze
async_schedule :freeze
end
|
#full_name ⇒ Object
30
31
32
|
# File 'lib/eye/group.rb', line 30
def full_name
@full_name ||= "#{app_name}:#{@name}"
end
|
#logger_tag ⇒ Object
22
23
24
|
# File 'lib/eye/group.rb', line 22
def logger_tag
full_name
end
|
115
116
117
|
# File 'lib/eye/group.rb', line 115
def monitor
chain_command :monitor
end
|
#resort_processes ⇒ Object
sort processes in name order
44
45
46
|
# File 'lib/eye/group.rb', line 44
def resort_processes
@processes = @processes.sort_by(&:name)
end
|
106
107
108
|
# File 'lib/eye/group.rb', line 106
def restart
chain_command :restart
end
|
#send_command(command, *args) ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
|
# File 'lib/eye/group.rb', line 85
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
123
124
125
|
# File 'lib/eye/group.rb', line 123
def signal(sig)
async_schedule :signal, sig
end
|
98
99
100
|
# File 'lib/eye/group.rb', line 98
def start
chain_command :start
end
|
#status_data(opts = {}) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/eye/group.rb', line 48
def status_data(opts = {})
plist = @processes.map { |p| p.status_data(opts) }
h = { name: name, type: :group, subtree: plist }
h[:debug] = debug_data if opts[: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
71
72
73
74
75
76
77
78
79
|
# File 'lib/eye/group.rb', line 71
def status_data_short
h = {}
@processes.each do |p|
state = p.state
h[state] ||= 0
h[state] += 1
end
{ name: (@name == '__default__' ? 'default' : @name), type: :group, states: h }
end
|
102
103
104
|
# File 'lib/eye/group.rb', line 102
def stop
async_schedule :stop
end
|
#sub_object?(obj) ⇒ Boolean
145
146
147
|
# File 'lib/eye/group.rb', line 145
def sub_object?(obj)
@processes.include?(obj)
end
|
#unmonitor ⇒ Object
119
120
121
|
# File 'lib/eye/group.rb', line 119
def unmonitor
async_schedule :unmonitor
end
|
#update_config(cfg) ⇒ Object
34
35
36
37
|
# File 'lib/eye/group.rb', line 34
def update_config(cfg)
@config = cfg
@full_name = nil
end
|
#user_command(cmd) ⇒ Object
127
128
129
|
# File 'lib/eye/group.rb', line 127
def user_command(cmd)
async_schedule :user_command, cmd
end
|