python工程,kafka消息对接转换成配置文件并完成类似看门狗监控linux系统进程,定期清理日志
wangrong
2025-04-05 88f9100edcba9581214c1a0acc23cd33a821a9c6
update the Gate start always
1个文件已修改
20 ■■■■■ 已修改文件
main.py 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
main.py
@@ -284,28 +284,20 @@
        try:
            current_time = datetime.now()
            current_hour = current_time.hour
            if stop_start_hour <= current_hour < stop_end_hour:
                logging.info("Within 00:00 - 05:00, stopping all monitored processes.")
                for process in process_list:
                    process_name = process.get("process_name")
                    if not process_name or process_name=="Gate":
                        continue
            for process in process_list:
                process_name = process.get("process_name")
                if stop_start_hour <= current_hour < stop_end_hour and process_name!="Gate":
                    pids = get_process_pids(process_name)
                    if pids:
                        stop_process(pids)
            else:
                for process in process_list:
                    process_name = process.get("process_name")
                    if not process_name:
                        continue
                        stop_process(pids)
                else:
                    pids = get_process_pids(process_name)
                    if not pids:
                        logging.warning(f"Process {process_name} is not running, starting...")
                        start_process(process)
        except Exception as e:
            logging.error(f"Monitoring processes encountered an exception: {e}")
        time.sleep(interval_seconds)  # 按配置时间间隔检查