chore(gateway): quiet provider startup logs

This commit is contained in:
Peter Steinberger
2026-01-02 19:58:40 +00:00
parent 675420013d
commit e368e56246
2 changed files with 136 additions and 132 deletions

View File

@@ -2096,41 +2096,35 @@ export async function startGatewayServer(
}; };
}; };
const startTelegramProvider = async () => { const startTelegramProvider = async () => {
if (telegramTask) return; if (telegramTask) return;
const cfg = loadConfig(); const cfg = loadConfig();
if (!cfg.telegram) { if (cfg.telegram?.enabled === false) {
telegramRuntime = { telegramRuntime = {
...telegramRuntime, ...telegramRuntime,
running: false, running: false,
lastError: "not configured", lastError: "disabled",
}; };
logTelegram.info("skipping provider start (telegram not configured)"); if (isVerbose()) {
return; logTelegram.debug("telegram provider disabled (telegram.enabled=false)");
} }
if (cfg.telegram?.enabled === false) { return;
telegramRuntime = { }
...telegramRuntime, const { token: telegramToken } = resolveTelegramToken(cfg, {
running: false, logMissingFile: (message) => logTelegram.warn(message),
lastError: "disabled", });
}; if (!telegramToken.trim()) {
logTelegram.info("skipping provider start (telegram.enabled=false)"); telegramRuntime = {
return; ...telegramRuntime,
} running: false,
const { token: telegramToken } = resolveTelegramToken(cfg, { lastError: "not configured",
logMissingFile: (message) => logTelegram.warn(message), };
}); // keep quiet by default; this is a normal state
if (!telegramToken.trim()) { if (isVerbose()) {
telegramRuntime = { logTelegram.debug("telegram provider not configured (no TELEGRAM_BOT_TOKEN)");
...telegramRuntime, }
running: false, return;
lastError: "not configured", }
};
logTelegram.info(
"skipping provider start (no TELEGRAM_BOT_TOKEN/telegram config)",
);
return;
}
let telegramBotLabel = ""; let telegramBotLabel = "";
try { try {
const probe = await probeTelegram( const probe = await probeTelegram(
@@ -2145,11 +2139,13 @@ export async function startGatewayServer(
logTelegram.debug(`bot probe failed: ${String(err)}`); logTelegram.debug(`bot probe failed: ${String(err)}`);
} }
} }
logTelegram.info(`starting provider${telegramBotLabel}`); logTelegram.info(
telegramAbort = new AbortController(); `starting provider${telegramBotLabel}${cfg.telegram ? "" : " (no telegram config; token via env)"}`,
telegramRuntime = { );
...telegramRuntime, telegramAbort = new AbortController();
running: true, telegramRuntime = {
...telegramRuntime,
running: true,
lastStartAt: Date.now(), lastStartAt: Date.now(),
lastError: null, lastError: null,
mode: cfg.telegram?.webhookUrl ? "webhook" : "polling", mode: cfg.telegram?.webhookUrl ? "webhook" : "polling",
@@ -2199,38 +2195,34 @@ export async function startGatewayServer(
}; };
}; };
const startDiscordProvider = async () => { const startDiscordProvider = async () => {
if (discordTask) return; if (discordTask) return;
const cfg = loadConfig(); const cfg = loadConfig();
if (!cfg.discord) { if (cfg.discord?.enabled === false) {
discordRuntime = { discordRuntime = {
...discordRuntime, ...discordRuntime,
running: false, running: false,
lastError: "not configured", lastError: "disabled",
}; };
logDiscord.info("skipping provider start (discord not configured)"); if (isVerbose()) {
return; logDiscord.debug("discord provider disabled (discord.enabled=false)");
} }
if (cfg.discord?.enabled === false) { return;
discordRuntime = { }
...discordRuntime, const discordToken =
running: false, process.env.DISCORD_BOT_TOKEN ?? cfg.discord?.token ?? "";
lastError: "disabled", if (!discordToken.trim()) {
}; discordRuntime = {
logDiscord.info("skipping provider start (discord.enabled=false)"); ...discordRuntime,
return; running: false,
} lastError: "not configured",
const discordToken = };
process.env.DISCORD_BOT_TOKEN ?? cfg.discord?.token ?? ""; // keep quiet by default; this is a normal state
if (!discordToken.trim()) { if (isVerbose()) {
discordRuntime = { logDiscord.debug("discord provider not configured (no DISCORD_BOT_TOKEN)");
...discordRuntime, }
running: false, return;
lastError: "not configured", }
};
logDiscord.info("skipping provider start (no DISCORD_BOT_TOKEN/config)");
return;
}
let discordBotLabel = ""; let discordBotLabel = "";
try { try {
const probe = await probeDiscord(discordToken.trim(), 2500); const probe = await probeDiscord(discordToken.trim(), 2500);
@@ -2241,8 +2233,10 @@ export async function startGatewayServer(
logDiscord.debug(`bot probe failed: ${String(err)}`); logDiscord.debug(`bot probe failed: ${String(err)}`);
} }
} }
logDiscord.info(`starting provider${discordBotLabel}`); logDiscord.info(
discordAbort = new AbortController(); `starting provider${discordBotLabel}${cfg.discord ? "" : " (no discord config; token via env)"}`,
);
discordAbort = new AbortController();
discordRuntime = { discordRuntime = {
...discordRuntime, ...discordRuntime,
running: true, running: true,
@@ -2293,27 +2287,32 @@ export async function startGatewayServer(
}; };
}; };
const startSignalProvider = async () => { const startSignalProvider = async () => {
if (signalTask) return; if (signalTask) return;
const cfg = loadConfig(); const cfg = loadConfig();
if (!cfg.signal) { if (!cfg.signal) {
signalRuntime = { signalRuntime = {
...signalRuntime, ...signalRuntime,
running: false, running: false,
lastError: "not configured", lastError: "not configured",
}; };
logSignal.info("skipping provider start (signal not configured)"); // keep quiet by default; this is a normal state
return; if (isVerbose()) {
} logSignal.debug("signal provider not configured (no signal config)");
if (cfg.signal?.enabled === false) { }
signalRuntime = { return;
...signalRuntime, }
running: false, if (cfg.signal?.enabled === false) {
lastError: "disabled", signalRuntime = {
}; ...signalRuntime,
logSignal.info("skipping provider start (signal.enabled=false)"); running: false,
return; lastError: "disabled",
} };
if (isVerbose()) {
logSignal.debug("signal provider disabled (signal.enabled=false)");
}
return;
}
const signalCfg = cfg.signal; const signalCfg = cfg.signal;
const signalMeaningfullyConfigured = Boolean( const signalMeaningfullyConfigured = Boolean(
signalCfg.account?.trim() || signalCfg.account?.trim() ||
@@ -2323,17 +2322,20 @@ export async function startGatewayServer(
typeof signalCfg.httpPort === "number" || typeof signalCfg.httpPort === "number" ||
typeof signalCfg.autoStart === "boolean", typeof signalCfg.autoStart === "boolean",
); );
if (!signalMeaningfullyConfigured) { if (!signalMeaningfullyConfigured) {
signalRuntime = { signalRuntime = {
...signalRuntime, ...signalRuntime,
running: false, running: false,
lastError: "not configured", lastError: "not configured",
}; };
logSignal.info( // keep quiet by default; this is a normal state
"skipping provider start (signal config present but missing required fields)", if (isVerbose()) {
); logSignal.debug(
return; "signal provider not configured (signal config present but missing required fields)",
} );
}
return;
}
const host = cfg.signal?.httpHost?.trim() || "127.0.0.1"; const host = cfg.signal?.httpHost?.trim() || "127.0.0.1";
const port = cfg.signal?.httpPort ?? 8080; const port = cfg.signal?.httpPort ?? 8080;
const baseUrl = cfg.signal?.httpUrl?.trim() || `http://${host}:${port}`; const baseUrl = cfg.signal?.httpUrl?.trim() || `http://${host}:${port}`;
@@ -2398,27 +2400,32 @@ export async function startGatewayServer(
}; };
}; };
const startIMessageProvider = async () => { const startIMessageProvider = async () => {
if (imessageTask) return; if (imessageTask) return;
const cfg = loadConfig(); const cfg = loadConfig();
if (!cfg.imessage) { if (!cfg.imessage) {
imessageRuntime = { imessageRuntime = {
...imessageRuntime, ...imessageRuntime,
running: false, running: false,
lastError: "not configured", lastError: "not configured",
}; };
logIMessage.info("skipping provider start (imessage not configured)"); // keep quiet by default; this is a normal state
return; if (isVerbose()) {
} logIMessage.debug("imessage provider not configured (no imessage config)");
if (cfg.imessage?.enabled === false) { }
imessageRuntime = { return;
...imessageRuntime, }
running: false, if (cfg.imessage?.enabled === false) {
lastError: "disabled", imessageRuntime = {
}; ...imessageRuntime,
logIMessage.info("skipping provider start (imessage.enabled=false)"); running: false,
return; lastError: "disabled",
} };
if (isVerbose()) {
logIMessage.debug("imessage provider disabled (imessage.enabled=false)");
}
return;
}
const cliPath = cfg.imessage?.cliPath?.trim() || "imsg"; const cliPath = cfg.imessage?.cliPath?.trim() || "imsg";
const dbPath = cfg.imessage?.dbPath?.trim(); const dbPath = cfg.imessage?.dbPath?.trim();
logIMessage.info( logIMessage.info(

View File

@@ -35,11 +35,8 @@ export async function buildProviderSummary(
if (!telegramEnabled) { if (!telegramEnabled) {
lines.push(chalk.cyan("Telegram: disabled")); lines.push(chalk.cyan("Telegram: disabled"));
} else { } else {
const { token: telegramToken } = effective.telegram const { token: telegramToken } = resolveTelegramToken(effective);
? resolveTelegramToken(effective) const telegramConfigured = Boolean(telegramToken?.trim());
: { token: "" };
const telegramConfigured =
Boolean(effective.telegram) && Boolean(telegramToken);
lines.push( lines.push(
telegramConfigured telegramConfigured
? chalk.green("Telegram: configured") ? chalk.green("Telegram: configured")