所以我找到了一个解决方案,可以从我的 ubuntu 服务器自动化我闪亮的应用程序。
我的 Apache Airflow 工具已经在 AWS 上的 Ubuntu 服务器上启动并运行。
假设您想从服务器部署它,请运行以下命令来安装 R-base 和依赖项:
sudo su -c "echo 'deb http://archive.linux.duke.edu/cran/bin/linux/ubuntu trusty/' >> /etc/apt/sources.list"
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get dist-upgrade -y
sudo apt-get install r-base -y
sudo su --c "R -e \"install.packages('shiny', repos='https://cran.rstudio.com/')\""
sudo su --c "R -e \"install.packages('fpp', repos='https://cran.rstudio.com/')\""
sudo su --c "R -e \"install.packages('rmarkdown', repos='https://cran.rstudio.com/')\""
sudo su --c "R -e \"install.packages('ggplot2', repos='https://cran.rstudio.com/')\""
sudo apt-get install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
R、Shiny 和所需包安装成功后,我们将检查 R 是否安装成功(您将看到交互式 R 终端如下所示):
R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
从 R 终端运行以下命令以安装依赖项和 rsconnect 包:
install.packages('devtools')
install.packages('rsconnect')
键入“q()”退出 R 终端。
现在我们需要在我们的 sudo 命令中设置 R 中的工作目录,以便在 shinyapps.io 网络服务器服务器上部署仪表板。在运行命令之前,请确保您已经在 R 中添加了令牌。您可以使用它或参考以下链接:
https://shiny.rstudio.com/articles/shinyapps.html
现在运行以下命令在 shinyapps.io 上部署应用程序:
sudo -i R -e "rsconnect::deployApp(appDir = '/your/ubuntu/Directory_Path', launch.browser = FALSE, forceUpdate = TRUE)"