1
0
Fork 0

Add agenda worker setup

This commit is contained in:
Ethanell 2020-11-24 01:09:20 +01:00
parent 1ad5056ba7
commit 84c932d3f9
2 changed files with 19 additions and 0 deletions

18
agenda/index.js Normal file
View file

@ -0,0 +1,18 @@
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);
};

View file

@ -119,4 +119,5 @@ function onListening() {
? "pipe " + addr ? "pipe " + addr
: "port " + addr.port; : "port " + addr.port;
debug("Listening on " + bind); debug("Listening on " + bind);
require("../agenda")(app);
} }