Skip to content
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

Add randomPort function, and add quiet option for startServer #234

Merged
merged 4 commits into from Aug 30, 2019
Merged

Conversation

@wch
Copy link
Collaborator

wch commented Aug 28, 2019

Closes #194, closes #233. The quiet option suppresses messages that are normally printed to console (and can't be intercepted with capture.output).

Update: This PR now adds a new function, randomPort.

Testing notes. The code below should have the behavior as described.

port <- 5001
# Start server
s <- startServer("127.0.0.1", port, list())


# Should print out "createTcpServer: address already in use", and throw an error
startServer("127.0.0.1", port, list())

# Should throw error only (and not print "createTcpServer: address already in use")
startServer("127.0.0.1", port, list(), quiet = TRUE)

# Should print "createTcpServer: address already in use" and return NULL
tryCatch(
  startServer("127.0.0.1", port, list()),
  error = function(e) {}
)

# Should just print NULL
tryCatch(
  startServer("127.0.0.1", port, list(), quiet = TRUE),
  error = function(e) {}
)



# Should return a random open port
randomPort()

# Should return 5002 (because 5001 is already taken)
randomPort(min = port, max = port + 1)
@wch wch requested a review from jcheng5 Aug 28, 2019
@jcheng5

This comment has been minimized.

Copy link
Member

jcheng5 commented Aug 29, 2019

@wch Did you want this in the upcoming release of httpuv? Or the next one?

@wch

This comment has been minimized.

Copy link
Collaborator Author

wch commented Aug 30, 2019

I was hoping to get it in this release. Actually, it might make sense to add in some code that finds an available port, as described in rstudio/shiny#2562.

@wch wch changed the title Add quiet option for startServer Add randomPort function, and add quiet option for startServer Aug 30, 2019
@wch wch force-pushed the wch-start-quiet branch from 4321523 to 19b6d36 Aug 30, 2019
R/random_port.R Show resolved Hide resolved
@wch wch merged commit f4d57a0 into master Aug 30, 2019
1 of 2 checks passed
1 of 2 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@wch wch deleted the wch-start-quiet branch Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.