feat: enforce strict AI env validation and force close
This commit is contained in:
@@ -14,6 +14,11 @@ import { createGracefulShutdown } from "./shutdown.js";
|
||||
export async function initializeApp() {
|
||||
const logger = createChildLogger("bot");
|
||||
|
||||
if (!config.AI_LLM_API_KEY) {
|
||||
logger.error("AI_LLM_API_KEY is missing from environment. Force closing application as AI environment is required.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const token = config.DISCORD_TOKEN;
|
||||
logger.info(
|
||||
{ hasToken: token.length > 0, tokenLength: token.length },
|
||||
|
||||
@@ -44,6 +44,16 @@ export default async function processAnalysisRequest({
|
||||
conversationKey,
|
||||
messages,
|
||||
}: AnalysisWorkerRequest): Promise<AnalysisWorkerResponse> {
|
||||
if (!config.AI_LLM_API_KEY) {
|
||||
console.error(JSON.stringify({
|
||||
level: "FATAL",
|
||||
context: "aiAnalysisWorker",
|
||||
error: "AI_LLM_API_KEY is missing from environment. Force closing worker operation.",
|
||||
timestamp: new Date().toISOString(),
|
||||
}));
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
try {
|
||||
try {
|
||||
await ensureDb();
|
||||
|
||||
Reference in New Issue
Block a user