lib: improve cluster/primary code

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Ehsan Khakifirooz 2024-07-21 23:23:17 +01:00 committed by GitHub
parent e8c2acf5de
commit aca31b8e0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
};