Stop launching extra Comfy Pythons when the running instance is just busy.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user