feat(scraper): worker-only entry for horizontal scaling (Raspberry Pi nodes)
This commit is contained in:
parent
1ba598e7ae
commit
7c9bd10941
21
packages/scraper/src/worker-only.ts
Normal file
21
packages/scraper/src/worker-only.ts
Normal file
@ -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<void> {
|
||||||
|
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); });
|
||||||
Loading…
x
Reference in New Issue
Block a user