1
0
Fork 0
This repository has been archived on 2024-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
letu/agenda/index.js

19 lines
423 B
JavaScript
Raw Permalink Normal View History

2020-11-24 01:09:20 +01:00
const { Worker } = require("worker_threads");
let nb = 0;
function startWorker(workerArgs) {
let worker = new Worker(...workerArgs);
worker.on("error", (err) => {
console.error(err);
nb--;
if (nb > 0)
startWorker(workerArgs);
});
}
module.exports = (app) => {
const workerArgs = ["./agenda/worker.js", {workerData: app.get("config")}];
startWorker(workerArgs);
};