-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
WIP prompt if port is already in use. #101
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
FWIW I was working on a solution for the port issue here that doesn't use a prompt/notification but it's clear you put in a lot of work here so happy to give it to you if the powers that be accept. |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Hey @sotojuan yeah I saw you push too, since this is my quick hack maybe we can work on this fix. |
This doesn’t merge cleanly right now, could you rebase please? |
formattedErrors.forEach(message => { | ||
console.log(message); | ||
console.log(); | ||
rl.question('Something is already running at http://localhost:' + PORT + '. Would you like to run the app at another port instead? [Y/n] ', function(answer){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a nit, can you add a space between )
and {
: function(answer) {
@eanplatter should be fixed now. |
I'm not sure if we're supporting Node 0.12, if we are those will need to be anonymous functions since 0.12 doesn't support arrow functions. |
@mxstbr @eanplatter I've removed arrow functions for consistency |
@gaearon moved prompt to utilities. |
still checking out why ci failed. |
Why remove the ability to set a port via the environment? Using a tool like hotel works best when it can set the port for you, so removing that seems like a bad idea. Is there another way to set the port via command line? |
@queso did this ability exist before this PR? I don't believe any ability is being removed. |
For me, the error is slightly different:
I'm running Windows, and my company appears to have something called Appsense running something or other on port 3000, which I can't shut down (and would likely be breaking some IT policy if I did). I don't need any clever port detection/reassignment. Just give me a way of overriding it with a command line switch. |
It was not removed, this ability did not exist in the first place. We do plan to introduce it in some way. Please read #102. |
As far as I understand, this PR should solve temporarily solve the problem for you. We can discuss a broader solution in #102. Please bear in mind this project has existed for a couple of weeks, so we can‘t add all requested features at once. 😉 |
I misread a line of code... I was looking at 10c6adf#diff-1ab6f53c8795042e5d1f961d6e6b75e5L22 I read it backwards, false alarm. I actually think this PR would make it easier to override a port from the command line, so I would be interested in this. |
Squashed and merged with a few fixes via 2edf218. |
Newly created apps will now offer to run on a different port if the default is taken. And you can override the default with You can either create a new app or update the |
Works fine for me with 0.2.0. The code picked up that "Something is already running at port 3000" and offered to switch to another port. It picked port 3001 when I hit "y", and all good after that. |
(You can also just press as |
Just curious: why do you ask and why don't you just start on another port? In most case this user might answer "yes". |
You can press Enter to skip the message (it defaults to "yes"). We ask because sometimes people run two instances unintentionally (eg in another terminal tab) and don't actually want two processes. |
Based on create-react-app and specifically facebook/create-react-app#101
Based on create-react-app and specifically facebook/create-react-app#101 In production, will exit(1) if the port is in use.
Here's my initial attempt to #85