r - 使用 Dockerfile 的 R 并行计算和 Shiny Server
问题描述
我需要一些帮助来使用并行计算和future
Docker 容器内的闪亮包。当我在 shinyapps.io 中插入我的应用程序时,它可以正常工作,但是如果我使用 Docker,它会给我以下日志错误。
[2019-04-22T19:49:24.320] [INFO] shiny-server - Shiny Server v1.5.7.890 (Node.js v8.10.0) [2019-04-22T19:49:24.325] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2019-04-22T19:49:24.440] [INFO] shiny-server - Starting listener on 0.0.0.0:80
[2019-04-22T19:49:29.399] [INFO] shiny-server - Created bookmark state directory: /var/lib/shiny-server/bookmarks
[2019-04-22T19:49:29.401] [INFO] shiny-server - Created user bookmark state directory: /var/lib/shiny-server/bookmarks/shiny
[2019-04-22T19:50:30.486] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
[2019-04-22T19:50:30.488] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
[2019-04-22T19:50:30.489] [INFO] shiny-server - Error getting worker: Error: The application took too long to respond.
我的 Dockerfile 使用 R、闪亮服务器、与 Postgres 和 sqlite 的连接。如果我不使用future
它,它可以正常工作。
# Install R version 3.5
FROM r-base:3.5.1
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev \
libpq-dev
# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# Install SQLite
RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get -yq install sqlite3 && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install R packages that are required
# TODO: add further package if you need!
RUN R -e "install.packages(c('RSQLite', 'RPostgres', 'readxl', 'dplyr', 'lubridate', 'DT', 'billboarder', 'shiny', 'future'), repos='http://cran.rstudio.com/')"
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Give permission of READWRITE for the SQLite database
RUN chmod a+rw /srv/shiny-server/db/ /srv/shiny-server/db/*
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
对于一个示例应用程序,我尝试了一个 global.R 文件加载shiny
和future
执行类似的东西
library(shiny)
library(future)
plan(multiprocess)
future({print(1)})
使用最少的 ui.R (like FluidPage()
) 和 server.R (like server <- function(input, output) {}
)。我敢打赌,我使用的是 Windows 7 环境,这会导致multiprocess
.像这样,我还没有找到。先感谢您。
解决方案
推荐阅读
- scrapy - 如何限制 Scrapy 爬虫的链接级别?
- sql - 如何仅在该特定组内按结果查找组中未排序的一组行?
- jackson - 为什么我需要在我的 RestController 中包含 @JsonProperty
- reactjs - 如何正确测试 React with act
- c# - 应用程序仍然在 C# 的发布版本中使用 print() 吗?
- html - 弹性盒项目中的文本导致弹性盒项目展开
- mysql - 如何在 MYSQL 中编写查询以避免 CSV 中的 qoutes
- hibernate - Spring 应用程序在生成用于测试的 schmea 时报告“字段 'id' 没有默认值”
- javascript - html 在 fullcalender 版本 5 中被视为文本
- tensorflow - 当我尝试使用我的 GPU 时调用 model.fit() 时,Python 3.8.8 Jupyter 笔记本内核死机