Skip to content

Export randomPort() #2599

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Export randomPort() #2599

wants to merge 7 commits into from

Conversation

cpsievert
Copy link
Collaborator

Closes #2562

@cpsievert cpsievert requested a review from wch September 11, 2019 19:18
R/server.R Outdated
#' randomPort()
#' randomPort()
#' randomPort(cache = FALSE)
randomPort <- function(min = 3000L, max = 8000L,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it necessary to create and export this function? My sense was that httpuv::randomPort was sufficient to address #2562. I guess that httpuv::randomPort doesn't do the caching part, though. We should find out if the caching is desired for that issue.

Also, if we do keep this function, I don't it should have the same name as the function from httpuv. If both packages are attached, there will be a name conflict and the order of package loading will affect how code behaves.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It seems necessary if we want to make it easy for users to know and replicate exactly what Shiny does by default. By exporting we can have the default value of the port argument in runApp() show users exactly what it does, rather than it magically filling in the default (it's much less likely that people will read the docs, find httpuv::randomPort(), and know how to use it in a way that they're used to).

If that's a strong enough argument to export, maybe findPort() would be a better name.

}
else {
# Try up to 20 random ports
while (TRUE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I had in mind a much more targeted change -- basically, replacing this (inside the else) with httpuv::randomPort().

@cpsievert cpsievert requested a review from hadley September 12, 2019 15:47
@cpsievert cpsievert requested a review from jcheng5 September 12, 2019 16:22
@CLAassistant
Copy link

CLAassistant commented Oct 2, 2019

CLA assistant check
All committers have signed the CLA.

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.

Extract port finding code out of shinyApp
3 participants