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.
7 8 9 10 11 |
# File 'lib/bluepill/group.rb', line 7 def initialize(name, = {}) self.name = name self.processes = [] self.logger = [:logger] end |
Instance Attribute Details
#logger ⇒ Object
Returns the value of attribute logger.
4 5 6 |
# File 'lib/bluepill/group.rb', line 4 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/bluepill/group.rb', line 4 def name @name end |
#process_logger ⇒ Object
Returns the value of attribute process_logger.
5 6 7 |
# File 'lib/bluepill/group.rb', line 5 def process_logger @process_logger end |
#processes ⇒ Object
Returns the value of attribute processes.
4 5 6 |
# File 'lib/bluepill/group.rb', line 4 def processes @processes end |
Instance Method Details
#add_process(process) ⇒ Object
13 14 15 16 |
# File 'lib/bluepill/group.rb', line 13 def add_process(process) process.logger = self.logger.prefix_with(process.name) self.processes << process end |
#determine_initial_state ⇒ Object
24 25 26 27 28 |
# File 'lib/bluepill/group.rb', line 24 def determine_initial_state self.processes.each do |process| process.determine_initial_state end end |
#status(process_name = nil) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bluepill/group.rb', line 47 def status(process_name = nil) lines = [] if process_name.nil? prefix = self.name ? " " : "" lines << "#{self.name}:" if self.name self.processes.each do |process| lines << "%s%s(pid:%s): %s" % [prefix, process.name, process.actual_pid, process.state] if process.monitor_children? process.children.each do |child| lines << " %s%s: %s" % [prefix, child.name, child.state] end end end else self.processes.each do |process| next if process_name != process.name lines << "%s%s(pid:%s): %s" % [prefix, process.name, process.actual_pid, process.state] lines << process.statistics.to_s end end lines << "" end |
#tick ⇒ Object
18 19 20 21 22 |
# File 'lib/bluepill/group.rb', line 18 def tick self.processes.each do |process| process.tick end end |