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
fix(cargo-shuttle): prompt for new port if port is taken #1270
Conversation
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.
Overall looks good to me, just had some comments. Let's see what other maintainers think.
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.
Looking pretty good now!
Writing a test for this is probably a bit cumbersome. I want to do some manual testing when it's ready anyways.
In the mean time, you could take a look at the task of timing out the confirmation if there is no response within, say, 10 seconds. In that case, we could exit(1) actually.
👍🏻
👍🏻
Sure, but instead of exit(1) can we continue with suggested port? |
Yeah, we can do that. We'll see what others think as well. |
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.
LGTM, thanks!
Thanks 😊, I'm trying for the timeout feature but that doesn't seems easy one, I'll be able to invest more time on weekend |
I double checked, and we do need to send in |
Sure @jonaro00 , I'll work and complete this port checking at least. Since you have already provided lots of info so it seems easily doable. However I'm facing challenge for the timeout feature. If you have some time then please share something. |
The timeout is not needed to complete this PR. I might take a look at it if I have time. |
@BadgerBloke How is progress on this? We aim to get this into a release this coming week, so I might hop in and finish any remaining work unless you are already on it ;) |
Yes @jonaro00 I'm on it and push the changes by today itself. |
@jonaro00 I think just by adding Please let me know if I'm still missing something if portpicker::is_free_tcp(port) && portpicker::is_free_tcp(port + 1) {
available_port = port;
break;
} |
Checking port+1 would not be enough if N > 2. So, if there are 3 services, and port 8000 is taken, it checks ports 8010, 8011, and 8012 in the next loop iteration. There can be issues with services not stopping and remaining open on port 8000. This is one of the reasons we are adding this feature. |
Ok, i think now I got the point, let me make the adjustment |
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.
Some comments
Thanks, let me fix that |
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.
Nice job!
I tested it locally, and while it is not bulletproof yet, I think this is good for merging now.
Thanks 😊 I've noted the timeout feature, please let me know other points I'll look into that |
We might not need it. For example, we could just make it take the new ports without asking, but print a warning about it instead. |
It sounds really good to me. There isn't much difference from UX point of view. In case do not want to run on suggested port then I can stop the started service. So, it's completely fine for me. Just a rough comparision:
*provided we supports |
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.
Looks good to me! I'm curious, why do we need a timeout here?
This was the idea behind it. Not strictly necessary ofc. #1270 (review) |
Thank you so much guys 😍 |
Description of change
cargo shuttle run
panic when the default port i.e., 8000 was already in use.This fix is checking that port 8000 is available or not?
If it finds 8000 free then it continues with earlier implementation but if it found the as not free then it is checking for available 2 consecutive ports using
find_available_port
function andfind_available_port
function returns the higher one. So that, rest of the implementation likeruntime::start
will work as expected.The ports range has been set as
default port - 1
to 65535 i.e.,7999 to 65535
Closes #1259
How has this been tested? (if applicable)
Test performed by spawning multiple instances of shuttle one after another and all of them was able to run properly on newer ports.