Add --launch-browser option to shiny run, and random port #329
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR, you can add
--launch-browserto theshiny runcommand and it will pop open a web browser on successful launch.It's also possible to ask Shiny to use a random port by passing
--port 0. This will be helpful for RStudio Server and other multiuser scenarios.Testing notes
shiny run --reload --launch-browser ...only launches a browser once, not on each autoreload (i.e. savingapp.pyshould cause existing browser window to autoreload but NOT for a new browser window to be launched)shiny run --launch-browser ...(i.e. without--reload) works; this uses a totally different codepath than--reload--port 0assigns random port numbers every time--port 0 --reloadkeeps the same random port number for each autoreload--autoreload-port 0also gives a random port number (do View Source on the app page, and look fordata-ws-urlPlus: all of the above, on RStudio Server
Plus: all of the above, on VSCode on RSW (
--launch-browserhas no effect)Plus: all of the above, on Windows in VSCode
Integration notes
This PR was designed to work well with RStudio Server and Workbench, but only on a branch that I'm still developing. Basically, the
--launch-browserlooks for theBROWSERenvironment variable; on my branch, RStudio Server sets this environment variable to a script that causes a new window to be opened by the IDE.