diff --git a/launch.bat b/launch.bat index 6bd9f6b5f..a3e582d7a 100644 --- a/launch.bat +++ b/launch.bat @@ -1,5 +1,5 @@ @echo off cd /d "%~dp0" echo Starting ComfyUI... -.venv\Scripts\python.exe main.py --auto-launch +.venv\Scripts\python.exe main.py --auto-launch --disable-api-nodes pause diff --git a/server.py b/server.py index 6d6ffdb48..3f6de128b 100644 --- a/server.py +++ b/server.py @@ -944,9 +944,18 @@ class PromptServer(): return web.Response(status=200) + @routes.get("/stopped") + async def get_stopped(request): + stopped_html = os.path.join(self.local_web_root, "extensions", "comfyui_exit", "stopped.html") + return web.FileResponse(stopped_html) + @routes.post("/shutdown") async def post_shutdown(request): - os._exit(0) + async def _exit(): + await asyncio.sleep(0.5) + os._exit(0) + asyncio.ensure_future(_exit()) + return web.Response(status=200) @routes.post("/interrupt") async def post_interrupt(request): diff --git a/web/extensions/comfyui_exit/exit_button.js b/web/extensions/comfyui_exit/exit_button.js index 8ed6d3480..d5c124c71 100644 --- a/web/extensions/comfyui_exit/exit_button.js +++ b/web/extensions/comfyui_exit/exit_button.js @@ -10,7 +10,7 @@ app.registerExtension({ icon: "pi pi-power-off", function: async () => { if (confirm("Shut down ComfyUI?")) { - await fetch("/shutdown", { method: "POST" }).catch(() => {}); + window.location.href = "/stopped"; } } } diff --git a/web/extensions/comfyui_exit/stopped.html b/web/extensions/comfyui_exit/stopped.html new file mode 100644 index 000000000..31b4841fe --- /dev/null +++ b/web/extensions/comfyui_exit/stopped.html @@ -0,0 +1,124 @@ + + + + + + ComfyUI — Stopped + + + +
+
+ + + + +
+ +

ComfyUI has stopped

+

The server has shut down cleanly.
To restart, run the launcher again.

+ +
+ +

Run from your terminal or shortcut:

+ launch.bat + + +
+ + +