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")