Coordinate shared GPU access across studio instances
This commit is contained in:
+12
-1
@@ -1,3 +1,4 @@
|
||||
import { assertSharedGpu, sharedGpuHeaders } from '~/server/utils/sharedGpu'
|
||||
import { LTX_NEGATIVE } from '~/utils/videoModels'
|
||||
import { createHash } from 'node:crypto'
|
||||
import { comfyJobPrefix } from '~/utils/outputNames'
|
||||
@@ -73,6 +74,9 @@ function configuredComfyBase() {
|
||||
}
|
||||
|
||||
export function getComfyHost() {
|
||||
// Shared studios must never bypass the reservation-enforcing proxy.
|
||||
const sharedHost = agentFrontDoorOrigin()
|
||||
if (sharedHost) return sharedHost
|
||||
if (comfyHostOverride) return viaAgentFrontDoor(comfyHostOverride) || comfyHostOverride
|
||||
return viaAgentFrontDoor(configuredComfyBase()) || configuredComfyBase()
|
||||
}
|
||||
@@ -83,6 +87,12 @@ export function comfyWsUrl(clientId: string) {
|
||||
|
||||
export async function comfyFetch(path: string, init?: RequestInit) {
|
||||
const url = `${getComfyHost()}${path}`
|
||||
if (init?.method && !['GET', 'HEAD'].includes(init.method.toUpperCase())) {
|
||||
await assertSharedGpu()
|
||||
const headers = new Headers(init.headers)
|
||||
for (const [key, value] of Object.entries(sharedGpuHeaders())) headers.set(key, value)
|
||||
init = { ...init, headers }
|
||||
}
|
||||
try {
|
||||
return await fetch(url, init)
|
||||
} catch (error) {
|
||||
@@ -623,7 +633,8 @@ async function purgeOnDesktop(opts: {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {})
|
||||
...(token ? { Authorization: `Bearer ${token}` } : {}),
|
||||
...sharedGpuHeaders()
|
||||
},
|
||||
body: JSON.stringify({
|
||||
imageName: imageNames[0] || '',
|
||||
|
||||
Reference in New Issue
Block a user