runpod-worker-comfy icon indicating copy to clipboard operation
runpod-worker-comfy copied to clipboard

how can I restart ComfyUI via the API?

Open vesper8 opened this issue 1 year ago • 2 comments

I have this custom extension that I added to ComfyUI Manager


import { app } from "../../scripts/app.js";
import { api } from "../../scripts/api.js"

app.registerExtension({
	name: "Comfy.ManagerMenu.extra.restart",
    async setup() {
        const menu = document.querySelector(".comfy-menu");

        const restartButton = document.createElement("button");
        restartButton.textContent = "Restart";
        restartButton.style.color = "#d72756";
        restartButton.onclick = () => {
            api.fetchApi("/manager/reboot");
        };

        const swlocaleBtn = document.getElementById("swlocale-button");
        menu.insertBefore(restartButton, swlocaleBtn.nextSibling);
    }
});

It adds a convenient restart button so you can save a click. It also shows how easy it is to access the internal api.

I am constantly having to manually restart ComfyUI whenever a workflow fails, or sometimes when I am switching workflows, some workflows will only work after restarting ComfyUI.

I would really like to be able to perform these commands by hitting the API that you expose in this package.

Is there any possibility to do that already? If not, why not? Is there another way to restart via API?

Many thanks!

vesper8 avatar Jul 04 '24 01:07 vesper8

@vesper8 thanks for bringing this up.

There is no way in the runpod-worker-comfy to restart the API yet. Does "/manager/reboot" come from the ComfyUI Manager? This is not standard ComfyUI, right?

Would you mind to share your use case? I would love to understand, why this feature would be needed in the real world. Does this happen locally when you are developing or do you also need this when the serverless API is deployed on RunPod?

TimPietrusky avatar Jul 29 '24 10:07 TimPietrusky

Hi @TimPietrusky, sorry for not getting back to you sooner. However I will say that this issue continues to haunt me to this day.. I still haven't figured out how to deal with this after all these months. I also can't understand why this isn't a widely asked-for thing in general.. not just with this package I mean but in general. I can't be the only one struggling with this?

My use case is straightforward.. I provision a new Runpod and use the base image. I then SSH over the public IP and run a bunch of commands to install nodes and download models. All of this happens as part of a unattended provisioning script.

Finally I would be ready to start sending workflows via the API that this package exposes.. but there's one problem.. a ComfyUI restart/reboot is needed for all my new nodes and models to take effect.

Yet somehow.. this seems like the hardest thing to do? I still can't figure it out.. the only way I can restart ComfyUI that I know is either via the web UI or by rebooting the whole server..

What the heck am I missing here? How is this not a big problem for everyone doing things fully programatically?

I would so love a solution!!! Many thanks!

vesper8 avatar Nov 26 '24 01:11 vesper8