From 42afa7c0bf38dc5b7361afcb9510d3770981cb83 Mon Sep 17 00:00:00 2001 From: SnapOtter Date: Thu, 30 Apr 2026 18:49:52 +0800 Subject: [PATCH] fix: eagerly start AI dispatcher at boot and log actual GPU status Replaces the misleading 'waiting for AI sidecar startup...' message that never resolved. The dispatcher now starts during server init, and the startup log shows the actual GPU detection result. --- apps/api/src/index.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 7fe143d8..2c3fdf11 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -1,7 +1,7 @@ import { randomUUID } from "node:crypto"; import cors from "@fastify/cors"; import rateLimit from "@fastify/rate-limit"; -import { getDispatcherStatus, isGpuAvailable } from "@snapotter/ai"; +import { getDispatcherStatus, initDispatcher, isGpuAvailable } from "@snapotter/ai"; import { APP_VERSION } from "@snapotter/shared"; import { eq } from "drizzle-orm"; import Fastify from "fastify"; @@ -242,12 +242,13 @@ const cleanupCron = startCleanupCron(); // Start try { await app.listen({ port: env.PORT, host: "0.0.0.0" }); - const dispatcherStatus = getDispatcherStatus(); - const gpuLine = !dispatcherStatus.ready - ? "[INFO] GPU status: waiting for AI sidecar startup..." - : dispatcherStatus.gpu - ? "[INFO] GPU detected — AI tools will use CUDA acceleration" - : "[WARN] No GPU detected — AI tools will use CPU (slower)"; + + const dispatcherResult = await initDispatcher(); + const gpuLine = dispatcherResult.ready + ? dispatcherResult.gpu + ? "[INFO] GPU detected -- AI tools will use CUDA acceleration" + : "[WARN] No GPU detected -- AI tools will use CPU (slower)" + : "[WARN] AI sidecar did not start -- AI tools will use per-request Python (slower)"; console.log( [ `SnapOtter v${APP_VERSION} running on port ${env.PORT}`,