Skip to content

Automatically choose next open port#7

Closed
milankl wants to merge 4 commits into
EarthyScience:mainfrom
milankl:mk/autoport
Closed

Automatically choose next open port#7
milankl wants to merge 4 commits into
EarthyScience:mainfrom
milankl:mk/autoport

Conversation

@milankl

@milankl milankl commented May 14, 2026

Copy link
Copy Markdown
Contributor

Means one can do several browzarr calls after another to e.g. compare datasets across browser windows without manually specifying a new port

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request introduces an autoport feature that automatically increments the port number if the requested port is already tracked in the internal registry. It also updates function signatures to use the Integer type for ports and defines default constants. Feedback indicates that the use of warn() will cause a runtime error and must be replaced with the @warn macro. Additionally, the current port-checking logic only considers the internal registry and should be expanded to check for system-level port availability to ensure robustness.

Comment thread src/servers.jl Outdated
Comment thread src/servers.jl
Comment on lines +10 to +13
while autoport && haskey(SERVERS, port)
warn("Port $port is already in use, trying next port...")
port += 1
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The current implementation only checks if the port is present in the internal SERVERS dictionary. It does not check if the port is already bound by another process on the system. To more robustly find an 'open' port as the PR title suggests, you might want to handle potential 'address in use' errors during the HTTP.serve! call or use a utility to check system-level port availability.

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@lazarusA

Copy link
Copy Markdown
Member

oh... I just got the notification for this [PRs on GitHub keep not showing sometimes :/ ], and I did a different solution for this in #8

tcp = isnothing(port) ? Sockets.listen(0) : Sockets.listen(parse(IPAddr, host), port)

that finds automatically open ports. I think I will go for that instead.

@milankl

milankl commented May 15, 2026

Copy link
Copy Markdown
Contributor Author

Yes looks better than the while loop here. Closing in favour of #8

@milankl milankl closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants