You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Run Shiny applications or Plumber APIs as background jobs #5190
Several enterprising users have noticed that you can use the new Jobs tab to run Shiny applications in the background, using a multi-step process:
Create a host script that runs the application
Run the host script as a local job in the Jobs tab
Copy the URL from the script's output and open it in the Viewer (or an external browser with rstudoapi::translateLocalURL)
This is a nifty trick and popular enough that we could consider offering a gesture that embraces and simplifies this workflow, for example by having a checkbox in the Run App dropdown that says Run as Job. In this mode, the Shiny app would run as a background job in the Jobs tab, and you could continue to work as usual while interacting with the Shiny application. Of course, you wouldn't get debugging and would possibly lose other features (for example the run/reload/stop buttons have some edge cases to consider) but would be very helpful for some use cases.
Reacted by Hadley Wickham, Daniel Possenriede, James Blair, Vincent Nijs and William Kumler
This is very nice! Thanks for making the add-in @dracodoc.
@jmcphers Is there a way to use this feature and still be able to communicate with Rstudio? Now it seems that rstudioapi::isAvailable() gives FALSE and rstudioapi::getSourceEditorContext() won't work when run from the app.
One of the reasons this is going to be a little more involved than you might think is that most of the code that works with Shiny apps and Plumber APIs assumes that you can only run one at a time -- so there are a few singleton classes, and variables which track the "currently running Shiny app". An advantage of background jobs, of course, is that you can run more than one at once, but that means that we'll need to refactor a good deal of the code that handles the run state.
Activity
dracodoc commentedon Oct 18, 2019
I really like this feature and it's easy enough to implement, so I just did it here.

vnijs commentedon Dec 3, 2019
This is very nice! Thanks for making the add-in @dracodoc.
@jmcphers Is there a way to use this feature and still be able to communicate with Rstudio? Now it seems that
rstudioapi::isAvailable()givesFALSEandrstudioapi::getSourceEditorContext()won't work when run from the app.jmcphers commentedon Dec 3, 2019
Yup, if you use the development branch of rstudio and rstudioapi. See e.g. rstudio/rstudioapi#155
jmcphers commentedon Dec 6, 2019
One of the reasons this is going to be a little more involved than you might think is that most of the code that works with Shiny apps and Plumber APIs assumes that you can only run one at a time -- so there are a few singleton classes, and variables which track the "currently running Shiny app". An advantage of background jobs, of course, is that you can run more than one at once, but that means that we'll need to refactor a good deal of the code that handles the run state.