From ff481de91b5e2475e2acccfe07fe89b112962ef6 Mon Sep 17 00:00:00 2001 From: Rubin Bhandari Date: Fri, 6 Oct 2023 15:34:54 +0545 Subject: [PATCH] fix: dynamic worker file --- src/common/misc/pool.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/misc/pool.ts b/src/common/misc/pool.ts index e10cf895..513f223d 100644 --- a/src/common/misc/pool.ts +++ b/src/common/misc/pool.ts @@ -5,8 +5,15 @@ import { DynamicThreadPool, availableParallelism } from "poolifier"; const logger = new Logger("ThreadPool"); + +const workerFile = path.join( + __dirname, + `workers${path.extname(__filename)}` +); + + /* Creating a new thread pool with half of available threads and a maximum of available threads. */ -export const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), path.resolve(__dirname, "workers.js"), { +export const pool = new DynamicThreadPool(Math.floor(availableParallelism() / 2), availableParallelism(), workerFile, { enableTasksQueue: true, tasksQueueOptions: { concurrency: 8