From a4ff2ac0f0908bb0274f4e8cb7b0760b1525275f Mon Sep 17 00:00:00 2001 From: Ehsan Khakifirooz Date: Sun, 21 Jul 2024 23:23:17 +0100 Subject: [PATCH] lib: improve cluster/primary code PR-URL: https://github.com/nodejs/node/pull/53756 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Yagiz Nizipli Reviewed-By: Trivikram Kamat Reviewed-By: Matteo Collina --- lib/internal/cluster/primary.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/internal/cluster/primary.js b/lib/internal/cluster/primary.js index 107ab258a47e04..630704da8fe614 100644 --- a/lib/internal/cluster/primary.js +++ b/lib/internal/cluster/primary.js @@ -221,12 +221,12 @@ function emitForkNT(worker) { } cluster.disconnect = function(cb) { - const workers = ObjectKeys(cluster.workers); + const workers = ObjectValues(cluster.workers); if (workers.length === 0) { process.nextTick(() => intercom.emit('disconnect')); } else { - for (const worker of ObjectValues(cluster.workers)) { + for (const worker of workers) { if (worker.isConnected()) { worker.disconnect(); } @@ -358,8 +358,6 @@ Worker.prototype.disconnect = function() { }; Worker.prototype.destroy = function(signo) { - const proc = this.process; const signal = signo || 'SIGTERM'; - - proc.kill(signal); + this.process.kill(signal); };