diff --git a/src/index.ts b/src/index.ts index 1e623eae8..caa6d8c22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -347,8 +347,19 @@ async function main() { const snapshotConfig = loadSnapshotConfig(); if (snapshotConfig.enabled) { registerSnapshotFunction(sdk, kv, snapshotConfig.dir); + const snapshotIntervalMs = snapshotConfig.interval * 1000; + if (snapshotIntervalMs > 0) { + const snapshotTimer = setInterval(async () => { + try { + await sdk.trigger({ function_id: "mem::snapshot-create", payload: {} }); + } catch {} + }, snapshotIntervalMs); + snapshotTimer.unref(); + } bootLog( - `Git snapshots: ${snapshotConfig.dir} (every ${snapshotConfig.interval}s)`, + snapshotIntervalMs > 0 + ? `Git snapshots: ${snapshotConfig.dir} (every ${snapshotConfig.interval}s)` + : `Git snapshots: ${snapshotConfig.dir} (periodic timer disabled, SNAPSHOT_INTERVAL=0 — manual trigger only)`, ); }