feat(配置): 启动时用 zod 一次解析环境变量,有错拒绝启动
原来是 `Number(env ?? 默认值)` 散写:JUDGE_CONCURRENCY=two 得到 NaN 照样起;
DATABASE_URL 漏配就静默连上开发库的默认账号;AI_KEY 缺了要等第一次 AI 调用才报错。
- config.ts 一张 envSchema 覆盖全部变量,失败时列出所有问题后 exit 1
- 编译形态(线上)下 DATABASE_URL / REDIS_URL / JUDGE_SERVER_TOKEN 必须显式给,
dev 默认值指向本机 5433 / 6380,放进容器里只会连不上或连错
- 空字符串按未设置处理(compose 的 ${X:-} 展开就是空串)
- AI_KEY 为空启动时告警(AI 是可选功能,不退出)
- db/index.ts 改读 config.databaseUrl;flowchart/run.ts 的 provider / model 改读 config
实跑核过:非法值被列出并拒绝启动;编译产物在仓库外无 env 时报三项必填,
给齐后 /health 正常;dev 的 serve / worker 照常起。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ca0dbbf0c5
commit
b38ad8ccee
3 files changed
+113
-40
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import type { FlowchartUpdate } from "@oj2/contract"
|
||||
import { eq } from "drizzle-orm"
|
||||
|
||||
import { config } from "../config"
|
||||
import { db, schema } from "../db"
|
||||
import { publishFlowchartUpdate } from "../events"
|
||||
import { completeChat } from "../services/ai"
|
||||
@@ -85,8 +86,8 @@ export async function evaluateFlowchart(
|
||||
aiFeedback: result.feedback,
|
||||
aiSuggestions: result.suggestions,
|
||||
aiCriteriaDetails: result.criteria,
|
||||
aiProvider: "deepseek",
|
||||
aiModel: process.env.AI_MODEL ?? "deepseek-flash",
|
||||
aiProvider: config.aiProvider,
|
||||
aiModel: config.aiModel,
|
||||
processingTime: (performance.now() - started) / 1000,
|
||||
evaluationTime: new Date().toISOString(),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user