7

I have a shiny app that runs fine on my local machine in RStudio. I have launched an AWS EC2 Ubuntu instance and installed R and shiny-server on it. When I access the app via browser, the app crashes at a (seemingly) arbitrary point.

Where can I access the R console log in order to be able to debug the code? There is no file in /var/log/shiny-server. Furthermore, the console in the browser simply states:

The application unexpectedly exited.

Diagnostic information is private. Please ask your system admin for permission if you need to check the R logs.

I have tried working with options(shiny.sanitize.errors = FALSE) to no avail.

dg99
  • 5,456
  • 3
  • 37
  • 49
Fabian Haribo
  • 191
  • 1
  • 5

2 Answers2

12

I found the solution. One has to add sanitize_errors false; to the shiny-server.conf and then restart shiny-server. Then the error log is displayed in the browsers console.

Ege Can
  • 195
  • 1
  • 10
Fabian Haribo
  • 191
  • 1
  • 5
3

To see logs:

Add the following line to your ui.R | server.R | app.R

options(shiny.sanitize.errors = FALSE)

Edit your shiny server .conf file:

sudo nano /etc/shiny-server/shiny-server.conf

add this line after "run_as" (don't forget ";" at the end)

preserve_logs true;

Note 1: You may need to add this preserve_log to force shiny server to save logs to files. (Remember to delete this setting after your debugging session. Shiny will start to create logs even for succesful app sessions and this can generate LOTS of log files)

Go to your log path:

$ cd /var/log/shiny-server/

Check the logs and see what's going on

$ nano appName-shinyuser-yyyymmdd-hhmmss-41509.log

In my case, the problem was just a missing package.

CoderGuy123
  • 6,219
  • 5
  • 59
  • 89
Luis Martins
  • 1,572
  • 12
  • 11