Skip to content
Closed
Changes from 3 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
10 changes: 6 additions & 4 deletions lib/cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,10 +684,12 @@ function workerInit() {

Worker.prototype.destroy = function() {
this.exitedAfterDisconnect = true;
if (!this.isConnected()) process.exit(0);
var exit = process.exit.bind(null, 0);
send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
process.once('disconnect', exit);
if (!this.isConnected()) {
process.exit();
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry if there was confusion. In my last comment, I said to either get rid of the var completely, or make it const. By get rid of, I meant make the 0 exit code inline, as it was prior to this PR. Without specifying the 0, this is a very subtle breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, right... good point :-)

@yorkie ... this should be process.exit(0) and below

} else {
send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
process.once('disconnect', () => process.exit());
}
Copy link
Member

Choose a reason for hiding this comment

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

Why not eliminate the bind() altogether?

if (!this.isConnected()) {
  process.exit(0);
} else {
  send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
  process.once('disconnect', () => process.exit(0));
}

};

function send(message, cb) {
Expand Down