Sha256: 1da5262496248cb58a5d3509ed5efd765791a1b2e84f6eff80f1da16017330fb

Contents?: true

Size: 636 Bytes

Versions: 1

Compression:

Stored size: 636 Bytes

Contents

module God
  module Conditions
    
    class ProcessExits < EventCondition
      attr_accessor :pid_file
      
      def valid?
        valid = true
        valid &= complain("You must specify the 'pid_file' attribute for :process_exits") if self.pid_file.nil?
        valid
      end
    
      def register
        pid = File.open(self.pid_file).read.strip.to_i
        
        EventHandler.register(pid, :proc_exit) {
          Hub.trigger(self)
        }
      end
      
      def deregister
        pid = File.open(self.pid_file).read.strip.to_i
        EventHandler.deregister(pid, :proc_exit)
      end
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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