Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cap UI port at max value #671

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions temporalcli/commands.server.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ func (t *TemporalServerStartDevCommand) run(cctx *CommandContext, args []string)
}
if opts.UIPort == 0 {
opts.UIPort = t.Port + 1000
if opts.UIPort > 65535 {
opts.UIPort = 65535
}
Comment on lines +76 to +78
Copy link
Collaborator

Choose a reason for hiding this comment

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

This increases the probability of 65535 being chosen randomly (vs. other port numbers). Can we instead do something like:

Suggested change
if opts.UIPort > 65535 {
opts.UIPort = 65535
}
if opts.UIPort > 65535 {
opts.UIPort = (t.Port - 1024) % (65536 - 1024) + 1024
}

(why keep the if-statement at all? To preserve backward compatibility with the existing +1000 behavior)

Copy link
Member Author

Choose a reason for hiding this comment

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

That's factually true, but, who cares? I can't imagine why that really matters at all.

if err := devserver.CheckPortFree(opts.UIIP, opts.UIPort); err != nil {
return fmt.Errorf("can't use default UI port %d (%d + 1000): %w", opts.UIPort, t.Port, err)
}
Expand Down
Loading