Download src/instrumentation.ts from lljz66/api: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/lljz66/api/resolve/main/src/instrumentation.ts
- Command line
-
hf download hf://spaces/lljz66/api/src/instrumentation.ts
-
curl -L -o instrumentation.ts https://huggingface.co/spaces/lljz66/api/resolve/main/src/instrumentation.ts
1.01 kB
| // Background automation: keeps the job index fresh and runs alert matching + | |
| // autopilot for every onboarded user without any manual action. | |
| export async function register() { | |
| if (process.env.NEXT_RUNTIME !== "nodejs") return; | |
| const g = globalThis as typeof globalThis & { __hfScheduler?: boolean }; | |
| if (g.__hfScheduler) return; | |
| g.__hfScheduler = true; | |
| const { runPipeline } = await import("@/lib/automation"); | |
| const { lastSyncAt } = await import("@/lib/sync"); | |
| const tick = async () => { | |
| try { | |
| const last = await lastSyncAt(); | |
| const needsSync = !last || Date.now() - last.getTime() > 6 * 3600_000; | |
| const r = await runPipeline({ sync: needsSync }); | |
| console.log( | |
| "[huntflow] pipeline ok · synced=" + needsSync + " users=" + r.users + " notifications=" + r.notifications + " queued=" + r.queued, | |
| ); | |
| } catch (e) { | |
| console.error("[huntflow] pipeline failed", e); | |
| } | |
| }; | |
| setTimeout(tick, 15_000); | |
| setInterval(tick, 30 * 60_000); | |
| } |