How to Run Multiple Apps

617 views
Skip to first unread message

Jason Watts

unread,
Apr 27, 2015, 7:44:16 PM4/27/15
to shiny-...@googlegroups.com
I am runnning Shiny server open source, however I am running only one app. I want to be able to run two at the same time. I have my current app in the directory srv/shiny-server and when I type 0.0.0.0:4949 into my browser my app runs. I then created a folder at srv/shiny-server/test and placed a exact copy of my app in that folder but when I type 0.0.0.0:4949/test it doesn’t run. Can somebody look at my config file below and tell me what to add to make it host both apps using the same port(4949)?

Thanks,


# Instruct Shiny Server to run applications as the user ':HOME_USER:', where
# possible (this username only takes effect in locations managed by
# 'user_dirs'). In all other locations, we should fall back to the 'shiny' user.
run_as :HOME_USER: shiny;

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

  # Define a location at the URL "/users"
  location /users {
   
    # 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;
  }

  # Define the location at the URL "/example1"
  location /example1 {
    app_dir /srv/shiny-server/sample-apps/hello;
    log_dir /var/log/shiny-server;
  }
}

# Define a server that listens on port 4949
server {
  listen 4949;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

Joe Cheng

unread,
Apr 27, 2015, 8:06:42 PM4/27/15
to Jason Watts, shiny-...@googlegroups.com
If you have an app in /srv/shiny-server that's mapped to http://hostname:4949/, then when you access http://hostname:4949/test it assumes that this is a URL within the app that's at /srv/shiny-server. And since files in Shiny apps aren't (and shouldn't be) web-accessible by default, this request will 404.

Probably the easiest fix is to explicitly add another configuration like "location /test { app_dir /srv/shiny-server/test; ... }", above the existing "location / {...}". You could also keep the config you have now, but move the Shiny app out of the root, and replace it with an index.html or add a redirect directive.

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/350a2a0d-5a1d-46b8-a252-5b152ad57882%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jason Watts

unread,
Apr 27, 2015, 8:17:10 PM4/27/15
to shiny-...@googlegroups.com
Thank you but I am still wrestling with it. Could give me a example by showing me the change in the config file?

Thanks,

Joe Cheng

unread,
Apr 27, 2015, 9:18:47 PM4/27/15
to Jason Watts, shiny-...@googlegroups.com
I haven't tried this exactly but something like:

# Define a server that listens on port 4949
server {
  listen 4949;

  location /test {


    # Host the directory of Shiny Apps stored in this directory
    app_dir /srv/shiny-server/test;

--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages