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

cluster: refine worker.destroy function #6502

Closed
wants to merge 4 commits into from

Conversation

yorkie
Copy link
Contributor

@yorkie yorkie commented May 1, 2016

Checklist
  • tests and code linting passes
  • a test and/or benchmark is included
  • documentation is changed or added
  • the commit message follows commit guidelines
Affected core subsystem(s)
  • cluster
Description of change

This PR just refines a cluster function and make the duplicated exit functions to be shared, so there is no tests or benchmarks could be provided :-)

@addaleax addaleax added the cluster Issues and PRs related to the cluster subsystem. label May 1, 2016
} else {
send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
process.once('disconnect', 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));
}

@jasnell
Copy link
Member

jasnell commented May 1, 2016

Generally LGTM with a nit and if CI is green: https://ci.nodejs.org/job/node-test-pull-request/2451/

@yorkie
Copy link
Contributor Author

yorkie commented May 1, 2016

@jasnell fixed the nit, could you help me run a new job, thank you :-)

var exit = process.exit.bind(null, 0);
send({ act: 'exitedAfterDisconnect' }, () => process.disconnect());
process.once('disconnect', exit);
var code = 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you drop this altogether or at least make it const.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cjihrig I choose to use your suggestion 1 because of the consistence with other functions in this module.

@jasnell
Copy link
Member

jasnell commented May 1, 2016

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

@yorkie
Copy link
Contributor Author

yorkie commented May 1, 2016

Fixed up, thank you @cjihrig @jasnell I thought the default is 0.

@jasnell
Copy link
Member

jasnell commented May 1, 2016

The default is 0 unless process.exitCode is set, if it is, then just calling process.exit() will use it's value instead of 0. in other words, process.exitCode = 4; process.exit() would exit with 4 and not 0. It's fairly non-obvious

@yorkie
Copy link
Contributor Author

yorkie commented May 1, 2016

So why did we introduce the exitCode as you described it as non-obvious culprit? Do we really need to set the default exit code for user-land?

@cjihrig
Copy link
Contributor

cjihrig commented May 1, 2016

LGTM

@jasnell
Copy link
Member

jasnell commented May 1, 2016

New CI: https://ci.nodejs.org/job/node-test-pull-request/2457/
LGTM if CI is green.

@yorkie
Copy link
Contributor Author

yorkie commented May 2, 2016

CI has been green :-) /cc @jasnell @cjihrig

@cjihrig
Copy link
Contributor

cjihrig commented May 2, 2016

Nice. Let's let this sit for another day or so in case anyone else wants to weigh in.

@yorkie
Copy link
Contributor Author

yorkie commented May 3, 2016

Ping @cjihrig

@cjihrig
Copy link
Contributor

cjihrig commented May 3, 2016

Thanks, landed in 4e905fa.

@cjihrig cjihrig closed this May 3, 2016
cjihrig pushed a commit that referenced this pull request May 3, 2016
This commit replaces process.exit.bind() with an arrow function
in Worker.prototype.destroy().

PR-URL: #6502
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@yorkie yorkie deleted the refine/cluster-worker branch May 3, 2016 17:02
@yorkie
Copy link
Contributor Author

yorkie commented May 3, 2016

:-) thanks for your advices too

Fishrock123 pushed a commit that referenced this pull request May 4, 2016
This commit replaces process.exit.bind() with an arrow function
in Worker.prototype.destroy().

PR-URL: #6502
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
joelostrowski pushed a commit to joelostrowski/node that referenced this pull request May 4, 2016
This commit replaces process.exit.bind() with an arrow function
in Worker.prototype.destroy().

PR-URL: nodejs#6502
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
@MylesBorins
Copy link
Contributor

Added dont-land for lts. Please feel free to let me know if I am incorrect in making this assumption

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants