This commit is contained in:
Sidney Anderson 2026-08-12 04:26:24 +08:00 committed by GitHub
commit 30bbfac212
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 3 deletions

View File

@ -25,21 +25,27 @@ export async function GET(request: NextRequest, { params }: { params: { jobID: s
data: { queue_position: newQueuePosition },
});
// make sure the queue is running
// make sure the queue exists and is running
const queue = await prisma.queue.findFirst({
where: {
gpu_ids: job.gpu_ids,
},
});
// if queue doesn't exist, create it
// if queue doesn't exist, create it and start it
if (!queue) {
await prisma.queue.create({
data: {
gpu_ids: job.gpu_ids,
is_running: false,
is_running: true,
},
});
} else {
// ensure the queue is running so the worker picks up the new job
await prisma.queue.update({
where: { id: queue.id },
data: { is_running: true },
});
}
await prisma.job.update({