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

Conversation

wch
Copy link
Collaborator

@wch 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 August 28, 2019 15:21
@jcheng5
Copy link
Member

jcheng5 commented Aug 29, 2019

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

@wch
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 merged commit f4d57a0 into master Aug 30, 2019
@wch wch deleted the wch-start-quiet branch August 30, 2019 20:33
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.

Have err_printf respect log_level Suppress the error message "createTcpServer: address already in use"
3 participants