# File lib/daemons/monitor.rb, line 7 def self.find(dir, app_name) pid = PidFile.find_files(dir, app_name, false)[0] if pid pid = PidFile.existing(pid) unless PidFile.running?(pid.pid) begin; pid.cleanup; rescue ::Exception; end return end monitor = allocate monitor.instance_variable_set(:@pid, pid) return monitor end nil end
# File lib/daemons/monitor.rb, line 88 def start(application_group) return if application_group.applications.empty? if @pid.kind_of?(PidFile) start_with_pidfile(application_group) else start_without_pidfile(application_group) end end
# File lib/daemons/monitor.rb, line 98 def stop begin pid = @pid.pid Process.kill(Application::SIGNAL, pid) Timeout.timeout(5, TimeoutError) do while Pid.running?(pid) sleep(0.1) end end rescue ::Exception => e puts "exception while trying to stop monitor process #{pid}: #{e}" puts 'deleting pid-file.' end # We try to remove the pid-files by ourselves, in case the monitor # didn't clean it up. begin; @pid.zap; rescue ::Exception; end end
Generated with the Darkfish Rdoc Generator 2.