fix: add debug logging for no-reply-api and moderator bot startup

This commit is contained in:
root
2026-03-03 18:50:23 +00:00
parent ed5ffd6c53
commit a842218921

View File

@@ -10,17 +10,23 @@ import { startModeratorPresence, stopModeratorPresence } from "./moderator-prese
let noReplyProcess: ChildProcess | null = null; let noReplyProcess: ChildProcess | null = null;
function startNoReplyApi(logger: { info: (m: string) => void; warn: (m: string) => void }, pluginDir: string, port = 8787): void { function startNoReplyApi(logger: { info: (m: string) => void; warn: (m: string) => void }, pluginDir: string, port = 8787): void {
logger.info(`dirigent: startNoReplyApi called, pluginDir=${pluginDir}`);
if (noReplyProcess) { if (noReplyProcess) {
logger.info("dirigent: no-reply API already running, skipping"); logger.info("dirigent: no-reply API already running, skipping");
return; return;
} }
const serverPath = path.resolve(pluginDir, "..", "no-reply-api", "server.mjs"); const serverPath = path.resolve(pluginDir, "..", "no-reply-api", "server.mjs");
logger.info(`dirigent: resolved serverPath=${serverPath}`);
if (!fs.existsSync(serverPath)) { if (!fs.existsSync(serverPath)) {
logger.warn(`dirigent: no-reply API server not found at ${serverPath}, skipping`); logger.warn(`dirigent: no-reply API server not found at ${serverPath}, skipping`);
return; return;
} }
logger.info(`dirigent: no-reply API server found, spawning process...`);
noReplyProcess = spawn(process.execPath, [serverPath], { noReplyProcess = spawn(process.execPath, [serverPath], {
env: { ...process.env, PORT: String(port) }, env: { ...process.env, PORT: String(port) },
stdio: ["ignore", "pipe", "pipe"], stdio: ["ignore", "pipe", "pipe"],
@@ -512,12 +518,23 @@ export default {
// Gateway lifecycle: start/stop no-reply API and moderator bot with the gateway // Gateway lifecycle: start/stop no-reply API and moderator bot with the gateway
api.on("gateway_start", () => { api.on("gateway_start", () => {
api.logger.info(`dirigent: gateway_start event received, pluginDir=${pluginDir}`);
// Check no-reply-api server file exists
const serverPath = path.resolve(pluginDir, "..", "no-reply-api", "server.mjs");
api.logger.info(`dirigent: checking no-reply-api server at ${serverPath}, exists=${fs.existsSync(serverPath)}`);
startNoReplyApi(api.logger, pluginDir); startNoReplyApi(api.logger, pluginDir);
const live = getLivePluginConfig(api, baseConfig as DirigentConfig); const live = getLivePluginConfig(api, baseConfig as DirigentConfig);
api.logger.info(`dirigent: config loaded, moderatorBotToken=${live.moderatorBotToken ? "[set]" : "[not set]"}`);
if (live.moderatorBotToken) { if (live.moderatorBotToken) {
api.logger.info("dirigent: starting moderator bot presence...");
startModeratorPresence(live.moderatorBotToken, api.logger); startModeratorPresence(live.moderatorBotToken, api.logger);
api.logger.info("dirigent: moderator bot presence starting"); api.logger.info("dirigent: moderator bot presence started");
} else {
api.logger.info("dirigent: moderator bot not starting - no moderatorBotToken in config");
} }
}); });