Automatically Detecting Dev and Prod Environment for RStudio Server Pro & RStudio Connect

Hello RStudio Community!

My work environment has a dev and prod for RSSP (RStudio Server Peo) and RSC (RStudio Connect). Based on dev and prod there are different steps depending on which environment we are in. I am looking for a way to detect the environment automatically so the developer does not need to manually specify it. The approach I am taking currently with shiny apps is to look at session$clientData$url_hostname. This is perfect because I can detect if its the dev or prod URL. However, I am looking for a solution for R scripts and Rmd's. Is there a way to get the URL of the current R session for RSSP?

The only thing I can find that is remotely close at the moment is if the Rmd is hosted on RSC then there are environment variables created that I can reference. This does get me to my end goal when the Rmd is hosted. I am curious if there a way to get the local RStudio Server URL, or in general a different approach to automatically knowing if I'm in dev or prod for RSSP/RSC. I am hoping there is a function I am missing that is similar to sessionInfo() that makes this easily accessible :grin:


The config package could help:

If you need to know the host directly on RStudio Server, you can check the HOSTNAME environment variable to see what host you're running on, or use system() to invoke the hostname command.

1 Like

Thanks, @jonathan, that does answer my question! Is there a way to get the hostname after the Rmd is hosted on RStudio Connect without setting up a config file?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.