Keep v1 as the default video graph, relay image edits to the Qwen Lightning box, and keep /api/health up if one Comfy host is unset. Co-authored-by: Cursor <cursoragent@cursor.com>
42 lines
1.6 KiB
TypeScript
42 lines
1.6 KiB
TypeScript
import { checkComfyHttp, fetchQueue } from '~/server/utils/comfyLifecycle'
|
|
import { comfyConfigured } from '~/server/utils/comfy'
|
|
import { imageComfyConfigured } from '~/server/utils/imageComfy'
|
|
import { checkImageComfyHttp, fetchImageQueue } from '~/server/utils/imageComfyLifecycle'
|
|
|
|
export default defineEventHandler(async () => {
|
|
const videoConfigured = comfyConfigured()
|
|
const imageConfigured = imageComfyConfigured()
|
|
const [comfy, queue, imageComfy, imageQueue] = await Promise.all([
|
|
videoConfigured
|
|
? checkComfyHttp().catch(() => ({ ok: false, host: '', stats: null }))
|
|
: Promise.resolve({ ok: false, host: '', stats: null }),
|
|
videoConfigured ? fetchQueue() : Promise.resolve({ running: 0, pending: 0 }),
|
|
imageConfigured
|
|
? checkImageComfyHttp().catch(() => ({ ok: false, host: '', stats: null }))
|
|
: Promise.resolve({ ok: false, host: '', stats: null }),
|
|
imageConfigured ? fetchImageQueue() : Promise.resolve({ running: 0, pending: 0 })
|
|
])
|
|
const busy = Boolean(comfy.ok && queue.running > 0)
|
|
const imageBusy = Boolean(imageComfy.ok && imageQueue.running > 0)
|
|
return {
|
|
ok: true,
|
|
service: useRuntimeConfig().public.instanceName || 'aigen',
|
|
comfy: {
|
|
ok: comfy.ok,
|
|
busy,
|
|
host: comfy.host || '',
|
|
queueRunning: queue.running,
|
|
queuePending: queue.pending,
|
|
stats: comfy.ok ? comfy.stats : undefined
|
|
},
|
|
imageComfy: {
|
|
configured: imageConfigured,
|
|
ok: imageComfy.ok,
|
|
busy: imageBusy,
|
|
host: imageComfy.host || '',
|
|
queueRunning: imageQueue.running,
|
|
queuePending: imageQueue.pending
|
|
}
|
|
}
|
|
})
|