Allow force-stopping Comfy when a stuck queue job blocks Sleep.
YuE ignored interrupt/clear and held the GPU; force stop is needed to unblock Studio when the queue will not drain. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -866,9 +866,11 @@ const server = http.createServer(async (req, res) => {
|
||||
return json(res, 200, { ok: true, asleep: false, proxyPort, ...launched })
|
||||
}
|
||||
if (req.method === 'POST' && url.pathname === '/stop') {
|
||||
const body = await readJson(req).catch(() => ({}))
|
||||
const force = body?.force === true || url.searchParams.get('force') === '1'
|
||||
const healthyPort = await syncProxy()
|
||||
const queue = healthyPort ? await fetchLocalQueue(healthyPort) : { running: 0, pending: 0, ok: false }
|
||||
if (queue.ok && (queue.running > 0 || queue.pending > 0)) {
|
||||
if (!force && queue.ok && (queue.running > 0 || queue.pending > 0)) {
|
||||
return json(res, 409, {
|
||||
ok: false,
|
||||
error: 'queue-busy',
|
||||
@@ -876,10 +878,15 @@ const server = http.createServer(async (req, res) => {
|
||||
pending: queue.pending
|
||||
})
|
||||
}
|
||||
if (force && healthyPort) {
|
||||
try {
|
||||
await fetch(`http://127.0.0.1:${healthyPort}/interrupt`, { method: 'POST', signal: AbortSignal.timeout(4000) })
|
||||
} catch { /* ignore */ }
|
||||
}
|
||||
const killed = await stopComfyProcesses()
|
||||
markAsleep()
|
||||
console.log(JSON.stringify({ src: 'comfy-host-agent', event: 'stopped', reason: 'stop', killed }))
|
||||
return json(res, 200, { ok: true, stopped: true, asleep: true, killed })
|
||||
console.log(JSON.stringify({ src: 'comfy-host-agent', event: 'stopped', reason: force ? 'force-stop' : 'stop', killed, queue }))
|
||||
return json(res, 200, { ok: true, stopped: true, asleep: true, killed, forced: force })
|
||||
}
|
||||
if (req.method === 'GET' && url.pathname === '/view') {
|
||||
const filename = String(url.searchParams.get('filename') || '')
|
||||
|
||||
Reference in New Issue
Block a user