Replace Comfy YuE with standalone YuEGP profile 1
This commit is contained in:
@@ -9,7 +9,7 @@ function reply(res, status, body) {
|
||||
}
|
||||
|
||||
/** Streams Comfy HTTP/WebSocket traffic; all mutations require the current reservation. */
|
||||
export function createGpuProxy({ target, reservation, authorized = () => true, markWork = () => {} }) {
|
||||
export function createGpuProxy({ target, reservation, authorized = () => true, markWork = () => {}, externalBusy = () => false }) {
|
||||
const server = http.createServer(async (req, res) => {
|
||||
const path = new URL(req.url || '/', 'http://localhost').pathname.replace(/\/+$/, '') || '/'
|
||||
// A global history list can expose another studio's prompts and outputs.
|
||||
@@ -55,6 +55,7 @@ export function createGpuProxy({ target, reservation, authorized = () => true, m
|
||||
try {
|
||||
if (req.method === 'GET' || req.method === 'HEAD') await forward()
|
||||
else {
|
||||
if (externalBusy()) { req.resume(); return reply(res, 409, { error: { message: 'YuEGP is using the GPU.' }, code: 'GPU_BUSY' }) }
|
||||
if (!authorized(req)) { req.resume(); return reply(res, 401, { error: 'Unauthorized' }) }
|
||||
await reservation.permit(String(req.headers['x-aigen-gpu-lease'] || ''), async () => { markWork(); await forward() })
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user