Skip to content

Conversation

@jcheng5
Copy link
Collaborator

@jcheng5 jcheng5 commented Sep 14, 2022

With this PR, you can add --launch-browser to the shiny run command 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

  • Tested that shiny run --reload --launch-browser ... only launches a browser once, not on each autoreload (i.e. saving app.py should cause existing browser window to autoreload but NOT for a new browser window to be launched)
  • Tested that shiny run --launch-browser ... (i.e. without --reload) works; this uses a totally different codepath than --reload
  • Tested that --port 0 assigns random port numbers every time
  • Tested that --port 0 --reload keeps the same random port number for each autoreload
  • Tested that --autoreload-port 0 also gives a random port number (do View Source on the app page, and look for data-ws-url

Plus: all of the above, on RStudio Server
Plus: all of the above, on VSCode on RSW (--launch-browser has 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-browser looks for the BROWSER environment variable; on my branch, RStudio Server sets this environment variable to a script that causes a new window to be opened by the IDE.

To have Shiny use a random port, use `--port 0`
@jcheng5 jcheng5 requested a review from cpsievert September 14, 2022 23:52
Now that we have random port numbers, just use those by default
Copy link
Collaborator

@cpsievert cpsievert left a comment

Choose a reason for hiding this comment

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

LGTM besides minor comments/nitpicks

@cpsievert cpsievert mentioned this pull request Sep 16, 2022
1 task
@jcheng5 jcheng5 merged commit bb55794 into main Sep 20, 2022
@jcheng5 jcheng5 deleted the launch-browser-2 branch September 20, 2022 07:36
@jcheng5
Copy link
Collaborator Author

jcheng5 commented Sep 20, 2022

@shalutiwari I did extensive testing of this, and additional testing will occur when we test this change in conjunction with the RStudio IDE integration.

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.

3 participants