feat: auto-increment port when requested port is in use#64
Merged
jfernandez merged 2 commits intojfernandez:mainfrom Mar 2, 2026
Merged
feat: auto-increment port when requested port is in use#64jfernandez merged 2 commits intojfernandez:mainfrom
jfernandez merged 2 commits intojfernandez:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds retry logic when binding the TCP listener so multiple mdserve instances can run concurrently by auto-incrementing the port when the requested port is already in use.
Changes:
- Introduces
bind_with_retry()to attempt binding across a port range whenAddrInUseoccurs. - Updates
serve_markdown()to use the actual bound port for display and--openbehavior, and prints a warning when falling back. - Adds a Tokio test validating the retry behavior when the initial port is occupied.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
@jzhuge, thanks for the feature! would you mind taking a look at CI and fix the failures? |
Contributor
Author
Fixed |
Owner
|
@jzhuge a few more asks:
|
62222c7 to
ed07952
Compare
Enables running multiple mdserve instances concurrently by automatically trying the next available port when the requested port is already bound. - Add MAX_PORT_ATTEMPTS constant (default 10) - Add bind_with_retry helper that attempts ports sequentially - Update serve_markdown to use bind_with_retry and print notice - Add test_bind_retries_on_addr_in_use test Closes jfernandez#63
ed07952 to
3e04831
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
test_bind_retries_on_addr_in_usevalidates retry behaviorCloses #63