4 Files & Directories

4.1 Program Files

The RStudio Connect installers place all program files into the /opt/rstudio-connect directory.

You should not need to change any files in the /opt/rstudio-connect hierarchy. Any alterations will be overwritten by subsequent re-installs or upgrades of RStudio Connect.

4.2 Configuration

The RStudio Connect configuration file is /etc/rstudio-connect/rstudio-connect.gcfg. You will edit this file to properly configure RStudio Connect for your organization.

A configuration management tool like Puppet or Chef can be used to maintain the rstudio-connect.gcfg file. We recommend that it be owned by root and have permissions 0600, as your configuration may need to contain passwords and other sensitive information.

RStudio Connect upgrades will not overwrite customizations to the rstudio-connect.gcfg file.

4.3 Server Log

The RStudio Connect server log is located at /var/log/rstudio-connect.log. This file is owned by root with permissions 0600.

If logrotate is available when RStudio Connect is installed, a logrotate configuration will be installed. The default configuration is to rotate the logfile daily. The old log file will be compressed and stored alongside the original log file with a .1.gz extension (then .2.gz, etc.). Logs will be maintained for 30 days.

4.4 Access Logs

The RStudio Connect HTTP access logs are located at /var/log/rstudio-connect.access.log. This file is owned by root with permissions 0600. Log files are stored in Apache Combined Log Format. See http://httpd.apache.org/docs/2.2/logs.html#combined for a description of this format.

If logrotate is available when RStudio Connect is installed, a logrotate configuration will be installed. The default configuration is to rotate the logfile daily. The old logfile will be compressed and stored alongside the original log file with a .1.gz extension (then .2.gz, etc.). Logs will maintained for 30 days.

4.5 Application Logs

Each R process launched by RStudio Connect produces output that is retained within the jobs subdirectory of the RStudio Connect data directory (see Section 4.6 for details). These directories and files are managed by the server. They are retained for 30 days and subsequently removed from the system.

Application logs are available in the RStudio Connect dashboard. The dashboard settings page for deployed content contains a Logs section containing execution details for each launched R process. Standard output and standard error are captured and available.

4.6 Variable Data

RStudio Connect manages uploaded Shiny applications, R Markdown documents, and plots. All of the variable data associated with this content is stored within the server’s data directory. This includes:

  • Deployment bundles as uploaded by the user.
  • Directories containing unpacked bundles, including R source code.
  • R packages, as demanded by the deployed code.
  • Rendered R Markdown documents.

The RStudio Connect data directory also contains information used by the server in managing your deployed content. This includes:

  • The RStudio Connect sqlite database and encryption key.
  • R process execution information including logged output.
  • Parameter overrides for R Markdown documents.

The default location for the RStudio Connect data directory is /var/lib/rstudio-connect. This can be customized by specifying an alternate DataDir in the Server section of your configuration file.

[Server]
DataDir = /mnt/rstudio-connect

The RStudio Connect database must exist on local storage. If the location for DataDir is not local storage but a networked location over NFS, configure the Dir setting in the Database section of your server configuration file.

[Server]
DataDir = /mnt/rstudio-connect

[Database]
Dir = /var/lib/rstudio-connect/db

4.6.1 Permissions

Data directory permissions are established by RStudio Connect as files are created. This section documents the general ownership patterns you will find under the RStudio Connect data directory.

Directories directly accessed from R applications will usually be owned by the Applications.RunAs user. This setting defaults to use an rstudio-connect account created during RStudio Connect installation. The rstudio-connect account has a default primary group also named rstudio-connect. We use the account and group name rstudio-connect throughout this section instead of referencing the property name.

Directories used during metrics collection are owned by the rstudio-connect user (customizable via the Metrics.User setting).

Learn more about customizing metrics collection in Section 13.1.

Directories not accessed by R applications or by the monitoring system will be owned by root.

/var/lib/rstudio-connect is owned by root with permissions 0701.

The R subdirectory contains R packages used when content is deployed. The entire R directory hierarchy needs to be owned by rstudio-connect. Files must have 0600 permissions and directories need 0700 permissions.

The packrat subdirectory contains R packages installed on behalf of deployed content. These packages are installed when content is deployed and subsequently used when an application or report executes. The entire packrat directory hierarchy needs to be owned by the rstudio-connect and the rstudio-connect group. Files must have 0640 permissions while directories need 0750 permissions.

The reports subdirectory is owned by root with 0711 permissions. This contains generated output for report content deployed with source. The nested directories are written to by R processes and are owned by rstudio-connect with 0700 permissions. Files contained in this hierarchy will have 0600 permissions.

The apps directory contains directories for each deployment. The top-level directory is owned by root with 0711 permissions. The first level of the apps hierarchy is a directory for each content deployment. These apps/A_ID directories are owned by rstudio-connect with 0700 permissions.

Beneath each apps/A_ID directory is a set of directories for each deployed bundle. The ownership and permissions for this hierarchy depend on whether or not the content is configured with a custom RunAs setting. Without a custom RunAs setting, permissions are simple: owned by rstudio-connect with directories having 0700 and files having 0600 permissions.

Learn more about using a custom RunAs in Section 9.3.

RStudio Connect needs a more complicated permission structure when content is configured with a custom RunAs setting. This is because the rstudio-connect user (Applications.RunAs) is used to install the necessary packages while the content-specific custom RunAs is used when running the deployed R code. The apps/A_ID/B_ID directory is owned by the custom RunAs with group ownership set to rstudio-connect. Permissions on this directory are 0750. The packrat subdirectory is owned by rstudio-connect with group ownership of rstudio-connect. File permissions on this directory and its sub-directories are 0750 while files have 0640 permissions. Other than the packrat directory, all files underneath apps/A_ID/B_ID have 0600 permissions and directories are given 0700.

All other data subdirectories are owned by root with 0700 permissions.

4.7 Backups

We recommend including the RStudio Connect configuration file in /etc/rstudio-connect as well as the variable data directory which defaults to /var/lib/rstudio-connect in your system backups. If you have configured the database to be stored outside the data directory, ensure that it is also included in the backup.

A running RStudio Connect server may be writing into the data directory if there are any active deployments, applications or documents. You should stop the RStudio Connect server before taking a backup.

$ sudo stop rstudio-connect
# Run appropriate backup steps here.
$ sudo start rstudio-connect

Your platform may need alternate commands to restart RStudio Connect. Please see Section 2.2 for instructions specific to your operating system version.