From 3f86b6141e778933b751e5abddd491f4f21e6b2b Mon Sep 17 00:00:00 2001 From: ansuz Date: Fri, 27 Mar 2020 15:14:45 -0400 Subject: [PATCH] rename worker processes --- lib/workers/{check-signature.js => crypto-worker.js} | 0 lib/workers/{compute-index.js => db-worker.js} | 0 lib/workers/index.js | 11 +++++++---- 3 files changed, 7 insertions(+), 4 deletions(-) rename lib/workers/{check-signature.js => crypto-worker.js} (100%) rename lib/workers/{compute-index.js => db-worker.js} (100%) diff --git a/lib/workers/check-signature.js b/lib/workers/crypto-worker.js similarity index 100% rename from lib/workers/check-signature.js rename to lib/workers/crypto-worker.js diff --git a/lib/workers/compute-index.js b/lib/workers/db-worker.js similarity index 100% rename from lib/workers/compute-index.js rename to lib/workers/db-worker.js diff --git a/lib/workers/index.js b/lib/workers/index.js index 8abdd2e15..16282b202 100644 --- a/lib/workers/index.js +++ b/lib/workers/index.js @@ -8,6 +8,9 @@ const { fork } = require('child_process'); const Workers = module.exports; const PID = process.pid; +const CRYPTO_PATH = 'lib/workers/crypto-worker'; +const DB_PATH = 'lib/workers/db-worker'; + Workers.initializeValidationWorkers = function (Env) { if (typeof(Env.validateMessage) !== 'undefined') { return void console.error("validation workers are already initialized"); @@ -16,7 +19,7 @@ Workers.initializeValidationWorkers = function (Env) { // Create our workers const workers = []; for (let i = 0; i < numCPUs; i++) { - workers.push(fork('lib/workers/check-signature.js')); + workers.push(fork(CRYPTO_PATH)); } const response = Util.response(function (errLabel, info) { @@ -37,7 +40,7 @@ Workers.initializeValidationWorkers = function (Env) { workers.splice(idx, 1); } // Spawn a new one - var w = fork('lib/workers/check-signature.js'); + var w = fork(CRYPTO_PATH); workers.push(w); initWorker(w); }); @@ -151,7 +154,7 @@ Workers.initializeIndexWorkers = function (Env, config, _cb) { if (idx !== -1) { workers.splice(idx, 1); } - var w = fork('lib/workers/compute-index'); + var w = fork(DB_PATH); initWorker(w, function (err) { if (err) { throw new Error(err); @@ -192,7 +195,7 @@ Workers.initializeIndexWorkers = function (Env, config, _cb) { nThen(function (w) { OS.cpus().forEach(function () { - initWorker(fork('lib/workers/compute-index'), w(function (err) { + initWorker(fork(DB_PATH), w(function (err) { if (!err) { return; } w.abort(); return void cb(err);