Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Error log in shiny-server deployed on AWS instance

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.

like image 432
Fabian Haribo Avatar asked Sep 07 '16 19:09

Fabian Haribo


People also ask

Why does my app work locally but not on my shiny server?

Your application may be dependent on packages that are installed and loaded in your environment, but aren't installed for the correct user on the Shiny Server. Make sure that all necessary packages are installed for the same user set under run_as in your Shiny Server configuration file.

How do you debug a shiny code?

RStudio Desktop Restart RStudio, start your Shiny app, right-click on it, and you'll see a new Inspect Element option. Click it to launch the Safari JavaScript debugger.


2 Answers

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.

like image 94
Fabian Haribo Avatar answered Sep 28 '22 02:09

Fabian Haribo


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.

like image 27
Luis Martins Avatar answered Sep 28 '22 03:09

Luis Martins