Add a Sleep GPU button that stops Comfy to free VRAM.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Towsty
2026-08-30 19:19:41 -05:00
co-authored by Cursor
parent 3a90892859
commit 64179dd516
4 changed files with 184 additions and 6 deletions
+22
View File
@@ -0,0 +1,22 @@
import { listJobs } from '~/server/utils/jobs'
import { listOwnersWithStudioQueues, listStudioJobs } from '~/server/utils/studioQueue'
import { requestComfySleep } from '~/server/utils/comfyLifecycle'
export default defineEventHandler(async () => {
const live = listJobs().filter(job => job.status === 'queued' || job.status === 'uploading' || job.status === 'running')
if (live.length) {
throw createError({
statusCode: 409,
statusMessage: 'A job is still running. Cancel it first, then sleep the GPU.'
})
}
for (const owner of listOwnersWithStudioQueues()) {
if (listStudioJobs(owner).some(job => job.status === 'running')) {
throw createError({
statusCode: 409,
statusMessage: 'A job is still running. Cancel it first, then sleep the GPU.'
})
}
}
return await requestComfySleep()
})