10

I have a shiny server running (1.3.0.403) on Red Hat Enterprise Linux Server release 6.5 (Santiago) running in a VM.

Some apps fail on startup with the notes that "The application failed to start. The application took too long to respond." Rebooting the shiny server allows the apps to work fine until the problem occurs again (within a day).

Others apps are fine. The sample apps work without issue.

We have a few different directories with different apps. For example,

├── shiny-server
│   ├── apps
│   ├── sample-apps
│   └── tutorials

The peculiar thing is that the app path seem to be the issue. For example, if I copy sample-apps/hello to apps/hello I get the same timeout issue with the same app code (whereas it works in the original path).

I've seen this post but the sample apps are very lightweight and speeding up the startup of your app doesn't seem like the solution.

Thanks,

Max

Gaurav Dave
  • 6,838
  • 9
  • 25
  • 39
topepo
  • 13,534
  • 3
  • 39
  • 52
  • After which time do you see the error message ("The application failed to start. The application took too long to respond.)? For me this sounds like the server has not enough power for this apps and after a while (when your memory is filling up) the server gets too slow and you get over a certain threshold. So does this server has a timeout threshold? This is very obvious so i guess you already checked that but this is just something that came to my mind. – Fabian Lurz May 02 '15 at 12:07

2 Answers2

10

This happened to me a few times. You need to increase the time for the app to initialize by setting the timeout to something like (app_init_timeout 300;) if you want to give it 5 mins (300 secs) in your shiny-server.conf file. The documentation is located here.

Here is an example /etc/shiny-server/shiny-server.conf:

# Tell Shiny Server that we want to run as the user whose 
# home directory we find the application in.
run_as :HOME_USER:;
app_init_timeout 300;
app_idle_timeout 300;

# Define a server that listens of port 3838.
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Allow users to host their own apps in ~/ShinyApps
    user_dirs;

    # Optionally, you can restrict the privilege of hosting Shiny applications
    # only to members of a particular Linux group.
    # members_of shinyUsers;
  }
}
Dave M
  • 101
  • 1
  • 6
3

Following this comment, I speed up the startup of my app by saving/loading the data as an .RData file:

# Save everything in an R Workspace
save.image(file="shiny.RData")

# Load (e.g. in global.R)
load("/PATH/TO/shiny.RData")

[If you don't want/need to save an entire R Workspace, can use save( object1, object2, ..., file="shiny.RData")]

Community
  • 1
  • 1
andyandy
  • 1,384
  • 2
  • 15
  • 25