Sha256: 3d1c112926ba335af726064d0be318adc92c955ebd61995a06d1746c45802085

Contents?: true

Size: 733 Bytes

Versions: 3

Compression:

Stored size: 733 Bytes

Contents

module God
  module Conditions
    
    class ProcessExits < EventCondition
      def valid?
        valid = true
        valid &= complain("You must specify the 'pid_file' attribute on the Watch for :process_exits") if self.watch.pid_file.nil?
        valid
      end
    
      def register
        pid = File.read(self.watch.pid_file).strip.to_i
        
        begin
          EventHandler.register(pid, :proc_exit) do
            Hub.trigger(self)
          end
        rescue StandardError
          raise EventRegistrationFailedError.new
        end
      end
      
      def deregister
        pid = File.read(self.watch.pid_file).strip.to_i
        EventHandler.deregister(pid, :proc_exit)
      end
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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