-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
replace portfinder with newport #332
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
Conversation
By using |
I think it's faster and also valid to let Node.js server to use a random clean port :) |
Still, this is a regression. As some people use this for serving static files permanently, |
This is one of my ideas : Default port is If set up over the port, when being given an error I think it is reasonable. If no port is set, the next port is randomly enabled when the 8080 is occupied for the service to start process.on('uncaughtException', function (err) {
if (err.syscall === 'listen' && err.port === portfinder.basePort) {
console.log(colors.red(portfinder.basePort + ' port is occupied, will randomly generate a new port!\n\n'));
newport(function (err, port) {
if (err) { throw err; }
listen(port);
});
}
});
if (!port) {
portfinder.basePort = 8080;
portfinder.getPort(function (err, port) {
if (err) { throw err; }
listen(port);
});
}
else {
listen(port);
} Thanks~ |
I'd personally rather like the opposite: I would like to specify a port (and have it fail if the port is used). In case I didn't care about a specific port and just want any port, I would pass This would work out using only Af few notes on your implementation:
|
Above is just one of my ideas, really lack of thinking~ Thank you very much~
This is good~ |
I'm assisting @indexzero in catching up with the backlog of PRs here. @derhuerst I'm 👍 on the approach you've outlined, and would be happy to accept a PR. @harttle would you be in support of the approach outlined in #332 (comment) I'm not keen to loose the ability to define a specific port, but having the option to fallback / have one found for me, sounds fab! |
@BigBlueHat OK, I'll make a PR this week later. |
@BigBlueHat I've implemented the |
@harttle just took this for a spin locally (bash in Windows 10) and it worked like a charm! I'm going to give this a bit for others to test, then possibly add it to the v0.10.0 release. Much thanks! |
I just find out that upgrade the |
@harttle oh. Even better. Mind squashing this PR into just the necessary code? |
It's Ok, there is only one commit actually, since I reset it before. |
@harttle looks like this is just the Thanks! |
Fixes: #325 and #215