lib/god/conditions/process_running.rb in god-0.7.0 vs lib/god/conditions/process_running.rb in god-0.7.3
- old
+ new
@@ -35,28 +35,23 @@
# end
class ProcessRunning < PollCondition
attr_accessor :running, :pid_file
def pid
- self.watch.pid || File.read(self.pid_file).strip.to_i
+ self.pid_file ? File.read(self.pid_file).strip.to_i : self.watch.pid
end
def valid?
valid = true
- valid &= complain("Attribute 'pid_file' must be specified", self) if self.watch.pid_file.nil? && self.pid_file.nil?
+ valid &= complain("Attribute 'pid_file' must be specified", self) if self.pid_file.nil? && self.watch.pid_file.nil?
valid &= complain("Attribute 'running' must be specified", self) if self.running.nil?
valid
end
def test
self.info = []
- # unless File.exist?(self.watch.pid_file)
- # self.info << "#{self.watch.name} #{self.class.name}: no such pid file: #{self.watch.pid_file}"
- # return !self.running
- # end
-
- pid = self.watch.pid
+ pid = self.pid
active = pid && System::Process.new(pid).exists?
if (self.running && active)
self.info.concat(["process is running"])
true
\ No newline at end of file