4 # Condition Symbol :process_exits
7 # Trigger when a process exits.
11 # +pid_file+ is the pid file of the process in question. Automatically
12 # populated for Watches.
16 # Trigger if process exits (from a Watch):
18 # on.condition(:process_exits)
20 # Trigger if process exits:
22 # on.condition(:process_exits) do |c|
23 # c.pid_file = "/var/run/mongrel.3000.pid"
25 class ProcessExits < EventCondition
27 self.info = "process exited"
38 EventHandler.register(pid, :proc_exit) do |extra|
39 formatted_extra = extra.size > 0 ? " #{extra.inspect}" : ""
40 self.info = "process #{pid} exited#{formatted_extra}"
44 msg = "#{self.watch.name} registered 'proc_exit' event for pid #{pid}"
45 applog(self.watch, :info, msg)
47 raise EventRegistrationFailedError.new
54 EventHandler.deregister(pid, :proc_exit)
56 msg = "#{self.watch.name} deregistered 'proc_exit' event for pid #{pid}"
57 applog(self.watch, :info, msg)
59 applog(self.watch, :error, "#{self.watch.name} could not deregister: no cached PID or PID file #{self.watch.pid_file} (#{self.base_name})")