Skip to content

Commit

Permalink
lib: improve cluster/primary code
Browse files Browse the repository at this point in the history
PR-URL: #53756
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
  • Loading branch information
ehsankhfr authored Jul 21, 2024
1 parent e8c2acf commit aca31b8
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/internal/cluster/primary.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
};

0 comments on commit aca31b8

Please sign in to comment.