Stop launching extra Comfy Pythons when the running instance is just busy.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-09-02 22:35:27 -05:00
co-authored by Cursor
parent eccf8c0081
commit c79cca39ae
3 changed files with 65 additions and 18 deletions
+19 -2
View File
@@ -677,10 +677,27 @@ const server = http.createServer(async (req, res) => {
markWork()
return json(res, 200, { ok: true, started: false, already: true, asleep: false, port: healthyPort, proxyPort })
}
if (lastLaunchAt && Date.now() - lastLaunchAt < 60_000) {
const listenPort = desktopListenPort()
const processAlive = lastProcessUp || await processUp().catch(() => false) || await pythonMainUp().catch(() => false)
const portBusy = await portInUse(listenPort)
const recentlySlow = [...probeSkipUntil.entries()].some(([, until]) => Date.now() < until)
if (processAlive || portBusy || recentlySlow) {
markWork()
lastProcessUp = true
if (portBusy) setProxyTarget(listenPort)
return json(res, 200, {
ok: true,
started: false,
already: true,
booting: true,
asleep: false,
port: portBusy ? listenPort : null,
proxyPort
})
}
if (lastLaunchAt && Date.now() - lastLaunchAt < 5 * 60_000) {
return json(res, 200, { ok: true, started: false, already: true, booting: true, asleep: false, proxyPort })
}
await taskkillImage('Comfy Desktop.exe')
stoppedByAgent = false
lastLaunchAt = Date.now()
const launched = await startComfy()