Bree is a Node.js and JavaScript job task scheduler with worker threads, cron, Date, and human syntax. Built for @ladjs, @forwardemail, @spamscanner, @cabinjs.
I am using Bree to execute Cron 1 which ingests data from an API to my DB. Cron 2 then executes and uses DB data to spawn several workers operating Cron 3 with different data for each worker. Cron 3 runs on an infinite loop for each worker, even though it has a closeWorkerAfterMs, process.exit(0) command and the parentPort.postMessage('done').
Cron 2: "cronFactory.js"
`
import path from 'path';
import ms from 'ms';
import Bree from 'bree';
import { PrismaClient } from '@prisma/client';
Hello,
I am using Bree to execute Cron 1 which ingests data from an API to my DB. Cron 2 then executes and uses DB data to spawn several workers operating Cron 3 with different data for each worker. Cron 3 runs on an infinite loop for each worker, even though it has a closeWorkerAfterMs, process.exit(0) command and the parentPort.postMessage('done').
Cron 2: "cronFactory.js"
` import path from 'path'; import ms from 'ms'; import Bree from 'bree'; import { PrismaClient } from '@prisma/client';
const cronFactory = async () => { const prisma = new PrismaClient();
};
cronFactory(); `
Cron 3: goalUpdate.js
`import { parentPort, workerData } from 'worker_threads';
const goalUpdate = async () => { if (parentPort) parentPort.postMessage('done'); else process.exit(0); };
goalUpdate();`
The console output runs infinitely, threadID's keep climbing. Help?