Class: Bluepill::Group
- Inherits:
-
Object
- Object
- Bluepill::Group
- Defined in:
- lib/bluepill/group.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name ⇒ Object
Returns the value of attribute name.
-
#process_logger ⇒ Object
Returns the value of attribute process_logger.
-
#processes ⇒ Object
Returns the value of attribute processes.
Instance Method Summary collapse
- #add_process(process) ⇒ Object
- #determine_initial_state ⇒ Object
-
#initialize(name, options = {}) ⇒ Group
constructor
A new instance of Group.
- #status(process_name = nil) ⇒ Object
- #tick ⇒ Object
Constructor Details
#initialize(name, options = {}) ⇒ Group
Returns a new instance of Group.
6 7 8 9 10 |
# File 'lib/bluepill/group.rb', line 6 def initialize(name, = {}) self.name = name self.processes = [] self.logger = [:logger] end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
3 4 5 |
# File 'lib/bluepill/group.rb', line 3 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/bluepill/group.rb', line 3 def name @name end |
#process_logger ⇒ Object
Returns the value of attribute process_logger.
4 5 6 |
# File 'lib/bluepill/group.rb', line 4 def process_logger @process_logger end |
#processes ⇒ Object
Returns the value of attribute processes.
3 4 5 |
# File 'lib/bluepill/group.rb', line 3 def processes @processes end |
Instance Method Details
#add_process(process) ⇒ Object
12 13 14 15 |
# File 'lib/bluepill/group.rb', line 12 def add_process(process) process.logger = logger.prefix_with(process.name) processes << process end |
#determine_initial_state ⇒ Object
21 22 23 |
# File 'lib/bluepill/group.rb', line 21 def determine_initial_state processes.each(&:determine_initial_state) end |
#status(process_name = nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/bluepill/group.rb', line 50 def status(process_name = nil) lines = [] if process_name.nil? prefix = name ? ' ' : '' lines << "#{name}:" if name processes.each do |process| lines << format('%s%s(pid:%s): %s', prefix, process.name, process.actual_pid, process.state) next unless process.monitor_children? process.children.each do |child| lines << format(' %s%s: %s', prefix, child.name, child.state) end end else processes.each do |process| next if process_name != process.name lines << format('%s%s(pid:%s): %s', prefix, process.name, process.actual_pid, process.state) lines << process.statistics.to_s end end lines << '' end |
#tick ⇒ Object
17 18 19 |
# File 'lib/bluepill/group.rb', line 17 def tick processes.each(&:tick) end |