Class: God::Conditions::ProcessRunning
- Inherits:
-
PollCondition
- Object
- Behavior
- God::Condition
- PollCondition
- God::Conditions::ProcessRunning
- Defined in:
- lib/god/conditions/process_running.rb
Instance Attribute Summary collapse
-
#running ⇒ Object
Returns the value of attribute running.
Attributes inherited from PollCondition
Attributes inherited from Behavior
Instance Method Summary collapse
Methods inherited from PollCondition
Methods inherited from God::Condition
Methods inherited from Behavior
#after_restart, #after_start, #after_stop, #before_restart, #before_start, #before_stop, generate, #prepare
Instance Attribute Details
#running ⇒ Object
Returns the value of attribute running.
5 6 7 |
# File 'lib/god/conditions/process_running.rb', line 5 def running @running end |
Instance Method Details
#test ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/god/conditions/process_running.rb', line 14 def test return !self.running unless File.exist?(self.watch.pid_file) pid = File.read(self.watch.pid_file).strip active = System::Process.new(pid).exists? (self.running && active) || (!self.running && !active) end |
#valid? ⇒ Boolean
7 8 9 10 11 12 |
# File 'lib/god/conditions/process_running.rb', line 7 def valid? valid = true valid &= complain("You must specify the 'pid_file' attribute on the Watch for :process_running") if self.watch.pid_file.nil? valid &= complain("You must specify the 'running' attribute for :process_running") if self.running.nil? valid end |