Stop idle Comfy after 30 minutes and add a Wake GPU poke.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -98,17 +98,59 @@ async function controlRequest(path: string, method = 'GET') {
|
||||
ok?: boolean
|
||||
http?: boolean
|
||||
process?: boolean
|
||||
processUp?: boolean
|
||||
asleep?: boolean
|
||||
lastActivityAt?: string | null
|
||||
idleMs?: number
|
||||
pid?: number
|
||||
started?: boolean
|
||||
already?: boolean
|
||||
port?: number | null
|
||||
proxyPort?: number | null
|
||||
stopped?: boolean
|
||||
error?: string
|
||||
status?: number
|
||||
}
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchComfyControlStatus() {
|
||||
return await controlRequest('/status')
|
||||
}
|
||||
|
||||
export async function requestComfyWake() {
|
||||
const { controlUrl } = settings()
|
||||
if (!controlUrl) {
|
||||
throw createError({
|
||||
statusCode: 503,
|
||||
statusMessage: 'COMFY_CONTROL_URL is not set. The studio cannot poke the Beast host agent.'
|
||||
})
|
||||
}
|
||||
const remote = await controlRequest('/start', 'POST')
|
||||
if (!remote) {
|
||||
throw createError({
|
||||
statusCode: 503,
|
||||
statusMessage: 'Beast host agent is unreachable. Confirm it is running on the desktop.'
|
||||
})
|
||||
}
|
||||
if (remote.ok === false) {
|
||||
throw createError({
|
||||
statusCode: Number(remote.status) || 502,
|
||||
statusMessage: 'Beast host agent refused to start Comfy.'
|
||||
})
|
||||
}
|
||||
return {
|
||||
ok: true,
|
||||
started: Boolean(remote.started),
|
||||
already: Boolean(remote.already),
|
||||
asleep: false,
|
||||
port: remote.port ?? null,
|
||||
proxyPort: remote.proxyPort ?? null
|
||||
}
|
||||
}
|
||||
|
||||
async function findLocalComfyProcess() {
|
||||
const platform = process.platform
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user