如何在shiny-server.conf中设置多个site_dir

时间:2017-03-31 04:46:13

标签: r rstudio shiny

目前我的shiny-server.conf看起来像这样:

# Instruct Shiny Server to run applications as the user "shiny"
run_as ubuntu shiny;

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

  # 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;
  }
}

有没有办法在这行中设置多个目录?

site_dir /srv/shiny-server

e.g。在其上添加/my_favorite/app_path1/

1 个答案:

答案 0 :(得分:1)

据我所知,问题是:"如何在闪亮服务器中设置多个目录"?

这是我的shiny-server.conf:

In [47]: dg = df.groupby(["AAR", "BYDEL"], as_index=False)["PERSONER"].sum()

In [48]: dg[dg.AAR == 1992].nlargest(3, "PERSONER")
Out[48]: 
    AAR  BYDEL  PERSONER
2  1992      3     67251
1  1992      2     62221
3  1992      4     47854

考虑到上述情况,您可以在n [51]: dg.head(15) Out[51]: AAR BYDEL PERSONER 0 1992 1 40595 1 1992 2 62221 2 1992 3 67251 3 1992 4 47854 4 1992 5 43688 5 1992 6 34303 6 1992 7 36746 7 1992 8 41668 8 1992 9 45305 9 1992 10 42748 10 1992 99 2187 11 1993 1 40925 12 1993 2 62583 13 1993 3 67783 14 1993 4 47589 下创建所需的目录,例如:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

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

  # 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;
  }
}

然后使用以下命令连接到每个应用程序: /srv/shiny-server+---/srv/shiny-server | +---Test | +---server.R | +---ui.R | +---Foo | +---server.R | +---ui.R 等。

当然,如果不希望在http://<ip address>:3838/Test下有物理目录,则可以对它们进行符号链接:例如,存储闪亮标准示例的目录http://<ip address>:3838/Foo是符号链接的/srv/shiny-server

也可以有每个用户的目录,但这似乎是不可能的范围。