From 573ed850b87749c35a0719bf2b15846375ff106e Mon Sep 17 00:00:00 2001 From: Jingyi Date: Tue, 11 Jun 2024 12:04:16 +0800 Subject: [PATCH] improved workflow delete check and delete folder --- build_scripts/comfy/comfy_proxy.py | 21 ++++++++++++++++++++- docker_image.sh | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/build_scripts/comfy/comfy_proxy.py b/build_scripts/comfy/comfy_proxy.py index c1bdf120..2c4743ee 100755 --- a/build_scripts/comfy/comfy_proxy.py +++ b/build_scripts/comfy/comfy_proxy.py @@ -1059,6 +1059,24 @@ if is_on_ec2: return web.Response(status=200, content_type='application/json', body=json.dumps({"result": False, "message": "can not delete current workflow"})) + i = 0 + start_n = 10000 + while i < 30: + port = start_n + i + file_path = f"/container/comfy_{port}" + i = i + 1 + if os.path.exists(file_path): + with open(file_path, 'r') as f: + content = f.read() + content = content.strip() + if content == name: + return web.Response(status=200, content_type='application/json', + body=json.dumps({"result": False, + "message": f"can not delete workflow " + f"because it is in use by {port}"})) + + os.system(f"rm -rf /container/workflows/{name}") + data = { "workflow_name_list": [name], } @@ -1098,7 +1116,8 @@ if is_on_ec2: if workflow_name == 'default' and not is_master_process: return web.Response(status=200, content_type='application/json', - body=json.dumps({"result": False, "message": "slave can not use default workflow"})) + body=json.dumps({"result": False, "message": "slave can not use default workflow " + "after initial"})) if workflow_name != 'default': if not check_workflow_exists(workflow_name): diff --git a/docker_image.sh b/docker_image.sh index e2633409..d7f3d360 100755 --- a/docker_image.sh +++ b/docker_image.sh @@ -18,7 +18,7 @@ while true; do if [ "$current_image" = "$image_target_name" ]; then echo "$current_image already pushed" - sleep 10 + sleep 30 continue fi current_image=$image_target_name