diff --git a/packages/scraper/src/worker-only.ts b/packages/scraper/src/worker-only.ts new file mode 100644 index 0000000..a1f011c --- /dev/null +++ b/packages/scraper/src/worker-only.ts @@ -0,0 +1,21 @@ +/** + * Worker-only entry — processes pg-boss jobs WITHOUT running the scheduler/cron + * or the startup zombie-cleanup (those belong to the single primary daemon). + * For horizontal scaling across extra machines (Raspberry Pis). + */ +import { createScheduler, registerWorkers } from "./scheduler"; + +async function runWorkerOnly(): Promise { + console.log("=== TIP Scraper WORKER-ONLY (no scheduler, no cron) ===\n"); + process.on("unhandledRejection", (reason) => { + const msg = reason instanceof Error ? reason.message : String(reason); + if ((msg.includes("ENOENT") || msg.includes("no such file")) && msg.includes("request_queues")) return; + console.error("[worker] Unhandled rejection:", reason); + process.exit(1); + }); + const boss = await createScheduler(); + await registerWorkers(boss); + console.log("Worker node ready — pulling jobs from shared pg-boss queues.\n"); +} + +runWorkerOnly().catch((err) => { console.error("Fatal:", err); process.exit(1); });