sys.exit(0) except OSError, e: sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror)) sys.exit(1) for f in sys.stdout, sys.stderr: f.flush() si = file(stdin, 'r') so = file(stdout, 'a+') se = file(stderr, 'a+', 0) os.dup2(si.fileno(), sys.stdin.fileno()) os.dup2(so.fileno(), sys.stdout.fileno()) os.dup2(se.fileno(), sys.stderr.fileno()) if __name__ == '__main__': topics = conf.get_topic_name().split(",") index = 0 tail = [] stop_flag = False if sys.platform != 'win32': daemonize() single = SingleInstance() if conf.get_test_path() == "null": use( passport(conf.get_passport().split(":")[0], conf.get_passport().split(":")[1])) set_router(conf.get_routers())
for l in lines: if l.startswith("CHECK_" + self.name) is False: continue else: ret.append(l) if len(ret) == 0: time.sleep(20) i += 1 continue else: break except Exception: print traceback.format_exc() raise Exception("read log file failed") finally: f.close() print "{COLLECT LOG INFO END}" return "".join(ret) if __name__ == '__main__': topics = conf.get_topic_name().split(",") i = 0 path = log_config.getLogPath() print str(topics) for t in topics: cp_path = conf.get_cp_path() cp_name = conf.get_cp_name().split(",")[i] i += 1 HealthCheck(path, cp_path, cp_name).check() pass