From 0b99d26e4b4da6ee78c9d6edbb2b2accb77b7037 Mon Sep 17 00:00:00 2001 From: ehsankhfr Date: Sun, 7 Jul 2024 20:00:26 +0100 Subject: [PATCH] lib: improve cluster/primary code --- 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); };