Relaunch ComfyUI when a process is up but the API never becomes ready.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-25 19:40:52 -05:00
co-authored by Cursor
parent f5829995c8
commit 1a271c05a4
2 changed files with 18 additions and 15 deletions
-1
View File
@@ -67,7 +67,6 @@ const server = http.createServer(async (req, res) => {
} }
if (req.method === 'POST' && url.pathname === '/start') { if (req.method === 'POST' && url.pathname === '/start') {
if (await httpUp()) return json(res, 200, { ok: true, started: false, already: true }) if (await httpUp()) return json(res, 200, { ok: true, started: false, already: true })
if (await processUp()) return json(res, 200, { ok: true, started: false, booting: true })
const launched = startComfy() const launched = startComfy()
return json(res, 200, { ok: true, ...launched }) return json(res, 200, { ok: true, ...launched })
} }
+18 -14
View File
@@ -223,23 +223,27 @@ async function ensureUnlocked(onStatus: StatusFn) {
processRunning: true processRunning: true
}) })
const ready = await pollUntilHealthy(cfg.bootPollAttempts, cfg.bootPollDelayMs, onStatus, 'booting', 'Waiting for ComfyUI to finish booting') const ready = await pollUntilHealthy(cfg.bootPollAttempts, cfg.bootPollDelayMs, onStatus, 'booting', 'Waiting for ComfyUI to finish booting')
if (!ready) { if (ready) {
throw createError({ await waitWhileBusy(onStatus)
statusCode: 503, onStatus({ state: 'online', message: 'ComfyUI online', host, processRunning: true })
statusMessage: 'ComfyUI is running but port 8188 never became ready. Check the desktop instance.' return
})
} }
await waitWhileBusy(onStatus) onStatus({
onStatus({ state: 'online', message: 'ComfyUI online', host, processRunning: true }) state: 'starting',
return message: 'ComfyUI is running but the API never came up. Attempting a relaunch...',
host,
processRunning: true
})
} }
onStatus({ if (!running) {
state: 'starting', onStatus({
message: 'ComfyUI is offline. Starting the desktop instance...', state: 'starting',
host, message: 'ComfyUI is offline. Starting the desktop instance...',
processRunning: false host,
}) processRunning: false
})
}
const started = await startComfy() const started = await startComfy()
if (!started.started) { if (!started.started) {
throw createError({ throw createError({