Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: improve cluster/primary code #53756

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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