From 2d9e351f4c753b56de20247800885f350bec5e1a Mon Sep 17 00:00:00 2001 From: "kyj@bowong.ai" Date: Mon, 19 May 2025 18:38:56 +0800 Subject: [PATCH] =?UTF-8?q?PERF=20=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E8=A1=8C=E5=AE=8C=E6=88=90=E5=90=8E=E9=87=8D?= =?UTF-8?q?=E5=90=AFComfyUI=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +- src/cluster/comfyui_v1.py | 63 ++++++++++++++++----------------------- src/cluster/comfyui_v2.py | 63 ++++++++++++++++----------------------- 3 files changed, 54 insertions(+), 75 deletions(-) diff --git a/.gitignore b/.gitignore index a23fe58..b361dc6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .pypirc .env -.idea \ No newline at end of file +.idea +test* \ No newline at end of file diff --git a/src/cluster/comfyui_v1.py b/src/cluster/comfyui_v1.py index 98fffa8..c3daad1 100644 --- a/src/cluster/comfyui_v1.py +++ b/src/cluster/comfyui_v1.py @@ -526,45 +526,34 @@ with comfyui_image.imports(): cleanup_span.set_tag("success", "false") cleanup_successful = False - logger.info("清理资源并重启ComfyUI") - restart_successful = True # 跟踪重启是否成功的标志 - with sentry_sdk.start_span(op="system.restart", description="重启ComfyUI") as restart_span: - try: - # 停止ComfyUI - with sentry_sdk.start_span(op="system.stop", description="停止ComfyUI") as stop_span: - cmd = "comfy stop" - subprocess.run(cmd, shell=True, check=True) - time.sleep(1) - stop_span.set_tag("success", "true") - # 设置状态为成功 - stop_span.set_status("ok") - except Exception as stop_error: - logger.error(f"停止ComfyUI失败: {stop_error}") - restart_span.set_data("stop_error", str(stop_error)) - restart_span.set_tag("stop_success", "false") - # 设置状态为错误 - restart_span.set_status("internal_error") - restart_successful = False - - try: - # 重启ComfyUI - with sentry_sdk.start_span(op="system.start", description="启动ComfyUI") as start_span: - cmd = "comfy launch --background" - subprocess.run(cmd, shell=True, check=True) - start_span.set_tag("success", "true") - # 设置状态为成功 - start_span.set_status("ok") - except Exception as start_error: - logger.error(f"启动ComfyUI失败: {start_error}") - restart_span.set_data("start_error", str(start_error)) - restart_span.set_tag("start_success", "false") - # 设置状态为错误 - restart_span.set_status("internal_error") - restart_successful = False - modal.experimental.stop_fetching_inputs() + # logger.info("清理资源并重启ComfyUI") + # with sentry_sdk.start_span(op="system.restart", description="重启ComfyUI") as restart_span: + # try: + # # 停止ComfyUI + # with sentry_sdk.start_span(op="system.stop", description="停止ComfyUI") as stop_span: + # cmd = "comfy stop" + # subprocess.run(cmd, shell=True, check=True) + # time.sleep(1) + # stop_span.set_tag("success", "true") + # except Exception as stop_error: + # logger.error(f"停止ComfyUI失败: {stop_error}") + # restart_span.set_data("stop_error", str(stop_error)) + # restart_span.set_tag("stop_success", "false") + # + # try: + # # 重启ComfyUI + # with sentry_sdk.start_span(op="system.start", description="启动ComfyUI") as start_span: + # cmd = "comfy launch --background" + # subprocess.run(cmd, shell=True, check=True) + # start_span.set_tag("success", "true") + # except Exception as start_error: + # logger.error(f"启动ComfyUI失败: {start_error}") + # restart_span.set_data("start_error", str(start_error)) + # restart_span.set_tag("start_success", "false") + # modal.experimental.stop_fetching_inputs() # 根据清理和重启结果设置总体清理状态 - if cleanup_successful and restart_successful: + if cleanup_successful: cleanup_span.set_status("ok") else: cleanup_span.set_status("internal_error") diff --git a/src/cluster/comfyui_v2.py b/src/cluster/comfyui_v2.py index 69a0d0a..3e8f5ea 100644 --- a/src/cluster/comfyui_v2.py +++ b/src/cluster/comfyui_v2.py @@ -495,45 +495,34 @@ with comfyui_latentsync_1_5_image.imports(): cleanup_span.set_tag("success", "false") cleanup_successful = False - logger.info("清理资源并重启ComfyUI") - restart_successful = True # 跟踪重启是否成功的标志 - with sentry_sdk.start_span(op="system.restart", description="重启ComfyUI") as restart_span: - try: - # 停止ComfyUI - with sentry_sdk.start_span(op="system.stop", description="停止ComfyUI") as stop_span: - cmd = "comfy stop" - subprocess.run(cmd, shell=True, check=True) - time.sleep(1) - stop_span.set_tag("success", "true") - # 设置状态为成功 - stop_span.set_status("ok") - except Exception as stop_error: - logger.error(f"停止ComfyUI失败: {stop_error}") - restart_span.set_data("stop_error", str(stop_error)) - restart_span.set_tag("stop_success", "false") - # 设置状态为错误 - restart_span.set_status("internal_error") - restart_successful = False - - try: - # 重启ComfyUI - with sentry_sdk.start_span(op="system.start", description="启动ComfyUI") as start_span: - cmd = "comfy launch --background" - subprocess.run(cmd, shell=True, check=True) - start_span.set_tag("success", "true") - # 设置状态为成功 - start_span.set_status("ok") - except Exception as start_error: - logger.error(f"启动ComfyUI失败: {start_error}") - restart_span.set_data("start_error", str(start_error)) - restart_span.set_tag("start_success", "false") - # 设置状态为错误 - restart_span.set_status("internal_error") - restart_successful = False - modal.experimental.stop_fetching_inputs() + # logger.info("清理资源并重启ComfyUI") + # with sentry_sdk.start_span(op="system.restart", description="重启ComfyUI") as restart_span: + # try: + # # 停止ComfyUI + # with sentry_sdk.start_span(op="system.stop", description="停止ComfyUI") as stop_span: + # cmd = "comfy stop" + # subprocess.run(cmd, shell=True, check=True) + # time.sleep(1) + # stop_span.set_tag("success", "true") + # except Exception as stop_error: + # logger.error(f"停止ComfyUI失败: {stop_error}") + # restart_span.set_data("stop_error", str(stop_error)) + # restart_span.set_tag("stop_success", "false") + # + # try: + # # 重启ComfyUI + # with sentry_sdk.start_span(op="system.start", description="启动ComfyUI") as start_span: + # cmd = "comfy launch --background" + # subprocess.run(cmd, shell=True, check=True) + # start_span.set_tag("success", "true") + # except Exception as start_error: + # logger.error(f"启动ComfyUI失败: {start_error}") + # restart_span.set_data("start_error", str(start_error)) + # restart_span.set_tag("start_success", "false") + # modal.experimental.stop_fetching_inputs() # 根据清理和重启结果设置总体清理状态 - if cleanup_successful and restart_successful: + if cleanup_successful: cleanup_span.set_status("ok") else: cleanup_span.set_status("internal_error")