Sha256: 49e2b242724bf7fd2ed5527d5e88c95cf62a12aab38940a00ec984848597a7f5

Contents?: true

Size: 723 Bytes

Versions: 4

Compression:

Stored size: 723 Bytes

Contents

module God
  module Conditions
    
    class ProcessRunning < PollCondition
      attr_accessor :running
      
      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
    
      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
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
god-0.3.0 lib/god/conditions/process_running.rb
god-0.4.0 lib/god/conditions/process_running.rb
god-0.4.1 lib/god/conditions/process_running.rb
god-0.4.3 lib/god/conditions/process_running.rb