Class: Pazuzu::Instance
- Inherits:
-
Object
- Object
- Pazuzu::Instance
- Includes:
- Utility::Runnable
- Defined in:
- lib/pazuzu/instance.rb
Constant Summary collapse
- SHUTDOWN_GRACE_TIME =
Time that we give processes to shut down normally on SIGTERM.
10.seconds
Instance Attribute Summary collapse
-
#command_line ⇒ Object
readonly
Returns the value of attribute command_line.
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#recovery_count ⇒ Object
readonly
Returns the value of attribute recovery_count.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Attributes included from Utility::Runnable
Instance Method Summary collapse
-
#attachable? ⇒ Boolean
Does this instance have any unattached PIDs running?.
-
#initialize(worker, index, root_path, command_line) ⇒ Instance
constructor
A new instance of Instance.
- #log_entries ⇒ Object
- #qname ⇒ Object
Methods included from Utility::Runnable
#run_state, #start!, #stop!, #wait_for_state_change!
Constructor Details
#initialize(worker, index, root_path, command_line) ⇒ Instance
Returns a new instance of Instance.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pazuzu/instance.rb', line 10 def initialize(worker, index, root_path, command_line) @worker = worker @index = index @logger = Utility::AnnotatedLogger.new( @worker.application.supervisor.logger, qname) @root_path = root_path @command_line = command_line @tailer = Utility::OutputTailer.new( :limit => 5000, :on_line => proc { |, line| @logger.info("[output] #{line}") }) @flap_limiter = Utility::RateLimiter.new(0.1) @recovery_count = 0 @cgroup = @worker.application.supervisor.cgroup_for_instance(self) super() end |
Instance Attribute Details
#command_line ⇒ Object (readonly)
Returns the value of attribute command_line.
40 41 42 |
# File 'lib/pazuzu/instance.rb', line 40 def command_line @command_line end |
#index ⇒ Object (readonly)
Returns the value of attribute index.
42 43 44 |
# File 'lib/pazuzu/instance.rb', line 42 def index @index end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
44 45 46 |
# File 'lib/pazuzu/instance.rb', line 44 def pid @pid end |
#recovery_count ⇒ Object (readonly)
Returns the value of attribute recovery_count.
45 46 47 |
# File 'lib/pazuzu/instance.rb', line 45 def recovery_count @recovery_count end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
43 44 45 |
# File 'lib/pazuzu/instance.rb', line 43 def root_path @root_path end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
41 42 43 |
# File 'lib/pazuzu/instance.rb', line 41 def worker @worker end |
Instance Method Details
#attachable? ⇒ Boolean
Does this instance have any unattached PIDs running?
27 28 29 |
# File 'lib/pazuzu/instance.rb', line 27 def attachable? run_state == :stopped && @cgroup.pids.any? end |
#log_entries ⇒ Object
35 36 37 38 |
# File 'lib/pazuzu/instance.rb', line 35 def log_entries source = qname return @tailer.entries.map { |(time, )| [source, time, ] } end |
#qname ⇒ Object
31 32 33 |
# File 'lib/pazuzu/instance.rb', line 31 def qname [@worker.qname, @index].join('.') end |