Gmail watcher: start when gateway (re)starts

This commit is contained in:
Jared Verdi
2026-01-01 23:09:44 -05:00
committed by Peter Steinberger
parent 11c7e05f43
commit ca9b0dbc88
2 changed files with 234 additions and 0 deletions

View File

@@ -174,6 +174,10 @@ import {
type HookMappingResolved,
resolveHookMappings,
} from "./hooks-mapping.js";
import {
startGmailWatcher,
stopGmailWatcher,
} from "../hooks/gmail-watcher.js";
ensureClawdisCliOnPath();
@@ -6859,6 +6863,20 @@ export async function startGatewayServer(
logBrowser.error(`server failed to start: ${String(err)}`);
}
// Start Gmail watcher if configured (hooks.gmail.account).
if (process.env.CLAWDIS_SKIP_GMAIL_WATCHER !== "1") {
try {
const gmailResult = await startGmailWatcher(cfgAtStart);
if (gmailResult.started) {
logHooks.info("gmail watcher started");
} else if (gmailResult.reason && gmailResult.reason !== "hooks not enabled" && gmailResult.reason !== "no gmail account configured") {
logHooks.warn(`gmail watcher not started: ${gmailResult.reason}`);
}
} catch (err) {
logHooks.error(`gmail watcher failed to start: ${String(err)}`);
}
}
// Launch configured providers (WhatsApp Web, Discord, Telegram) so gateway replies via the
// surface the message came from. Tests can opt out via CLAWDIS_SKIP_PROVIDERS.
if (process.env.CLAWDIS_SKIP_PROVIDERS !== "1") {
@@ -6917,6 +6935,7 @@ export async function startGatewayServer(
await stopDiscordProvider();
await stopSignalProvider();
await stopIMessageProvider();
await stopGmailWatcher();
cron.stop();
heartbeatRunner.stop();
broadcast("shutdown", {