Class: Eye::Group
Defined Under Namespace
Modules: Chain
Instance Attribute Summary collapse
#current_scheduled_command, #last_scheduled_at, #last_scheduled_command, #last_scheduled_reason
#logger
Instance Method Summary
collapse
included, #schedule, #schedule_history, #schedule_in, #scheduled_action, #scheduler_actions_list
Constructor Details
#initialize(name, config) ⇒ Group
Returns a new instance of Group.
14
15
16
17
18
19
20
21
|
# File 'lib/eye/group.rb', line 14
def initialize(name, config)
@name = name
@config = config
@logger = Eye::Logger.new(full_name)
@processes = Eye::Utils::AliveArray.new
@hidden = (name == '__default__')
debug 'created'
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def config
@config
end
|
#hidden ⇒ Object
Returns the value of attribute hidden.
12
13
14
|
# File 'lib/eye/group.rb', line 12
def hidden
@hidden
end
|
#name ⇒ Object
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
#add_process(process) ⇒ Object
32
33
34
|
# File 'lib/eye/group.rb', line 32
def add_process(process)
@processes << process
end
|
#break_chain ⇒ Object
110
111
112
113
114
|
# File 'lib/eye/group.rb', line 110
def break_chain
info "break chain"
scheduler.clear_pending_list
@chain_breaker = true
end
|
#clear ⇒ Object
116
117
118
|
# File 'lib/eye/group.rb', line 116
def clear
@processes = Eye::Utils::AliveArray.new
end
|
#debug_data ⇒ Object
64
65
66
|
# File 'lib/eye/group.rb', line 64
def debug_data
{:queue => scheduler_actions_list, :chain => chain_status}
end
|
#delete ⇒ Object
93
94
95
96
|
# File 'lib/eye/group.rb', line 93
def delete
async_schedule :delete
terminate
end
|
#full_name ⇒ Object
23
24
25
|
# File 'lib/eye/group.rb', line 23
def full_name
@full_name ||= "#{@config[:application]}:#{@name}"
end
|
#monitor ⇒ Object
98
99
100
|
# File 'lib/eye/group.rb', line 98
def monitor
chain_command :monitor
end
|
#resort_processes ⇒ Object
sort processes in name order
37
38
39
|
# File 'lib/eye/group.rb', line 37
def resort_processes
@processes = @processes.sort_by(&:name)
end
|
#restart ⇒ Object
89
90
91
|
# File 'lib/eye/group.rb', line 89
def restart
chain_command :restart
end
|
#send_command(command, *args) ⇒ Object
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/eye/group.rb', line 68
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, "#{command} by user"
end
end
|
#signal(sig) ⇒ Object
106
107
108
|
# File 'lib/eye/group.rb', line 106
def signal(sig)
async_schedule :signal, sig
end
|
#start ⇒ Object
81
82
83
|
# File 'lib/eye/group.rb', line 81
def start
chain_command :start
end
|
#status_data(debug = false) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/eye/group.rb', line 41
def status_data(debug = false)
plist = @processes.map{|p| p.status_data(debug) }
h = { name: name, type: :group, subtree: plist }
h.merge!(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
|
#stop ⇒ Object
85
86
87
|
# File 'lib/eye/group.rb', line 85
def stop
async_schedule :stop
end
|
#sub_object?(obj) ⇒ Boolean
120
121
122
|
# File 'lib/eye/group.rb', line 120
def sub_object?(obj)
@processes.include?(obj)
end
|
#unmonitor ⇒ Object
102
103
104
|
# File 'lib/eye/group.rb', line 102
def unmonitor
async_schedule :unmonitor
end
|
#update_config(cfg) ⇒ Object
27
28
29
30
|
# File 'lib/eye/group.rb', line 27
def update_config(cfg)
@config = cfg
@full_name = nil
end
|