数据科学与R语言 生物信息学分析生物信息学与算法

Shiny Server安装

2020-09-15  本文已影响0人  JeremyL

#为什么要使用Shiny Server

Shiny Server使用户可以在网络上托管和管理Shiny应用程序。Shiny是一个R包,运用反应式编程模型
简化Web程序开发。Shiny Server可以通过不同的URLs 和端口管理不同的R程序。

使用Shiny Server的好处有:

Shiny Server专业版(Shiny Server Professional)有跟多的功能:

#系统要求

Shiny Server当前仅能在Linux 操作系统运行,并且只支持64位系统:

#安装

Shiny Server安装之前需要先安装 R 和Shiny 包。

$ sudo apt-get install r-base

注意:如果您没有按如上所述添加CRAN Debian或Ubuntu存储库,则此命令将安装与您当前系统版本相对应的R版本。可能是老版本的R。

$ sudo su - -c "R -e \"install.packages('shiny', repos='http://cran.rstudio.com/')\""
或者
$ R
>install.packages('shiny')
>library("shiny")
$ sudo apt-get install gdebi-core
$ wget https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-1.5.14.948-amd64.deb
$ sudo gdebi shiny-server-1.5.14.948-amd64.deb

Shiny Server将会被安装到/opt/shiny-server/,主要的执行程序在/opt/shiny-server/bin/shiny-server。

#启动 
$ sudo systemctl start shiny-server 
#停止 
$ sudo systemctl stop shiny-server 
#重启
$ sudo systemctl restart shiny-server
#查看状态 
$ sudo systemctl status shiny-server 
#服务器重新初始化,但不会中断服务器当前进程或任何连接。
$ sudo systemctl kill -s HUP --kill-who=main shiny-server
$ sudo reload shiny-server
#shiny-server状态
$ sudo systemctl status shiny-server

IP:使用ip addr查看
端口默认:3838。

shiny
/etc/shiny-server/shiny-server.conf
/opt/shiny-server/config/default.config
$ vi  /etc/shiny-server/shiny-server.conf
# Define the user we should use when spawning R Shiny processes
run_as shiny;

# Define a top-level server which will listen on a port
server {
  # Instruct this server to listen on port 3838
  listen 3838;

  # Define the location available at the base URL
  location / {
    #### PRO ONLY ####
    # Only up tp 20 connections per Shiny process and at most 3 Shiny processes
    # per application. Proactively spawn a new process when our processes reach 
    # 90% capacity.
    utilization_scheduler 20 .9 3;
    #### END PRO ONLY ####

    # Run this location in 'site_dir' mode, which hosts the entire directory
    # tree at '/srv/shiny-server'
    site_dir /srv/shiny-server;
    
    # Define where we should put the log files for this location
    log_dir /var/log/shiny-server;
    
    # Should we list the contents of a (non-Shiny-App) directory when the user 
    # visits the corresponding URL?
    directory_index on;
  }
}

# Setup a flat-file authentication system. {.pro}
auth_passwd_file /etc/shiny-server/passwd;

# Define a default admin interface to be run on port 4151. {.pro}
admin 4151 {
  # Only permit the user named `admin` to access the admin interface.
  required_user admin;
}

#参考

Shiny Server Professional v1.5.14 Administrator's Guide

系列文章:
Shiny 初步了解
一个 Shiny app的基本组成部分

上一篇下一篇

猜你喜欢

热点阅读