Is there a way for the plumber script to know it is being run by RStudio Connect on the server (as opposed to my computer) ?

Hi everyone,

I'm building a Plumber API and it saves logs. When I test it on my RStudio desktop or the RStudio server I want the log to into the here::here("logs") folder.

However, when it is being run by RStudio connect on the server, I want to save the logs in a different path.

Is this possible? Maybe using interactive() ?

thanks,
Simon

Yes, there is, and there is also a package for this use case called config, available at CRAN. A good place to start is at the pkgdown documentation site at Manage Environment Specific Configuration Values • config

The config package describes this, but in a nutshell: Your Connect server will set an environment variable called R_CONFIG_ACTIVE that you can read and respond to.

The config package gives you a way to set you default values in a single config.yml file, and then your code can respond differently, depending on the active configuration.

1 Like

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.