Sha256: 1343c3d932570b3fff08bed88be4007eb1a23d5ba2de36dd932b50dba65c3e66

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

module God
  module Conditions
    
    class ProcessRunning < PollCondition
      attr_accessor :pid_file, :running
      
      def valid?
        valid = true
        valid &= complain("You must specify the 'pid_file' attribute for :process_running") if self.pid_file.nil?
        valid &= complain("You must specify the 'running' attribute for :process_running") if self.running.nil?
        valid
      end
    
      def test
        return !self.running unless File.exist?(self.pid_file)
        
        pid = File.open(self.pid_file).read.strip
        active = System::Process.new(pid).exists?
        
        (self.running && active) || (!self.running && !active)
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
god-0.2.0 lib/god/conditions/process_running.rb