Sha256: 901d892c23984fa49be77ffa36f9e0b4291b01d4b4d73335ba89f9407fce1f63
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module God module Conditions class ProcessRunning < PollCondition attr_accessor :running def valid? valid = true valid &= complain("Attribute 'pid_file' must be specified", self) if 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 = File.read(self.watch.pid_file).strip active = System::Process.new(pid).exists? if (self.running && active) self.info << "process is running" true elsif (!self.running && !active) self.info << "process is not running" true else if self.running self.info << "process is not running" else self.info << "process is running" end false end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
god-0.5.0 | lib/god/conditions/process_running.rb |