Add a Sleep GPU button that stops Comfy to free VRAM.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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()
|
||||
})
|
||||
Reference in New Issue
Block a user