psychTestR experiments can be hosted online using the open-source 'Shiny Server' software. This software can be installed on a Linux server. The following instructions detail how you can provision your own server if you don't already have one.

Note: Anthony Chmiel has very kindly put together a much more detailed guide that is available here. You are highly recommended to refer to this guide when setting up your own server.

Shiny Server

Shiny Server hosts Shiny apps so that they can be accessed over the Internet. psychTestR delivers experiments as Shiny apps, and therefore needs Shiny Server for deploying experiments online.

Shiny Server has a free open source version and a paid professional version. While the professional version comes with useful features, in particular sophisticated load management, it seems to be prohibitively expensive for research purposes. We've used the open source version in our own work, and have had no problems.

Provisioning a server with Shiny Server

Shiny Server requires a Linux server. There are various ways of obtaining your own server. Cloud-based providers, such as Amazon Web Services (AWS), provide a useful way of getting your own virtual server instead of having to buy and maintain physical hardware. The instructions below correspond to AWS because this is where our experience lies, but there are many competing cloud providers that could equivalently be used.

The overview of this stage is as follows:

Instructions covering both of these steps can be found here: https://aws.amazon.com/blogs/big-data/running-r-on-aws/. This link provides some additional functionality that you may not need, such as setting up a web-hosted instance of RStudio, and integrating the server with S3. However, it also provides a CloudFormation template that automates the setup of this configuration, so it still might save you time.

The following instructions may also be useful:

By default, Shiny Server runs on port 3838. We've found this problematic when testing participants in schools, because some firewalls block this port. We therefore recommend running Shiny Server on port 80. You can achieve this as follows:

Install psychTestR

You can install psychTestR on your server as follows:

if (!require(devtools)) install.packages("devtools")
devtools::install_github("pmcharrison/psychTestR")

Debugging

Sanitised error messages

Shiny defaults to sanitised error messages, which is often not desirable. We recommend disabling error sanitisation as follows:

Debugging tips

Hosting an experiment

Your experiment's source code should already be in the form of a directory containing the file app.R, which should contain the logic for defining your experiment. You should upload this directory to the directory /srv/shiny-server/. Our recommended approach is currently as follows:

Local files

psychTestR stores local files in the output/ subdirectory of your app's directory. These include session files and saved data. Do not delete these files unless you are happy with losing data. We recommend using the app's admin panel to delete these files if necessary.



pmcharrison/psychTestR documentation built on Sept. 30, 2023, 6:27 p.m.