How to detect when running on shinyapps.io?

28 views
Skip to first unread message

Eric Goldsmith

unread,
May 17, 2016, 8:40:04 AM5/17/16
to ShinyApps Users
Is there a way to detect if an application is running on shinyapps.io (vs. running locally)?

For example, in the Docker world, you can do this:

if (file.exists("/.dockerinit")) {
  # Running in a Docker container

}

Any equivalent for shinyapps.io?

Thanks,
Eric

Tareef Kawaf

unread,
May 17, 2016, 9:09:24 AM5/17/16
to Eric Goldsmith, ShinyApps Users
Hi Eric,
I don't think we have gotten this request in the past.  My guess is that easiest thing to do would be to have an environment variable that you test for, and just setting that environment variable in your local environment, but maybe someone else has a better way of doing it.  

-Tareef

--
You received this message because you are subscribed to the Google Groups "ShinyApps Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-use...@googlegroups.com.
To post to this group, send email to shinyap...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/ce75b3ee-2321-450c-8639-3d158c125c42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Usman Suleman

unread,
Aug 25, 2016, 5:38:58 PM8/25/16
to shinyapps.io Users
Here is something simple:
##
# Am I on shinyapps.io or running Local
#
isLocal <<- Sys.getenv('SHINY_PORT') == ""
if(isLocal) {
  cat(file=stderr(),"App running on Local ...\n")
} else {
  cat(file=stderr(),"App running on Shinyapps.io...\n")
} 
Reply all
Reply to author
Forward
0 new messages