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 <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
ehsankhfr authored and marco-ippolito committed Aug 19, 2024
1 parent 993bb3b commit a4ff2ac
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 a4ff2ac

Please sign in to comment.