R Shiny App 在 60 秒内超时,即使在 conf 文件中传递了 app_init_timeout 设置

如何解决R Shiny App 在 60 秒内超时,即使在 conf 文件中传递了 app_init_timeout 设置

我尝试将我的 R 闪亮应用程序容器化,该应用程序使用 docker 连接到 sql server 映像。如果我将其指向较小的数据集,该应用程序会加载一些初始数据并且工作正常,如果我在初始化步骤中加载大型数据集,该应用程序会开始给我超时。而实际的错误信息是

应用程序无法启动。

应用程序在初始化期间退出。

我查看了 R Documentation 并发现关于 app_init_timeout 每个应用程序的默认超时时间为 60 秒,可以通过设置此参数来增加,因此我将超时参数设置为 1800 秒但不幸的是,它对我的​​应用没有影响,并且在通常的 60 秒后超时。

我正在尝试将自定义的 server.conf 复制到 etc/shiny-server/shiny-server.conf,在那里我指定了增加的 app_init_timeout,如下所示:

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 / {
    site_dir /srv/shiny-server;
    log_dir /var/log/shiny-server;
    directory_index on;
    # Increase the timeout of the app
    app_init_timeout 3600;
    app_idle_timeout 3600;
  }  
}

我的 docker 文件是

FROM  rocker/shiny-verse

#update all packages
RUN apt-get update

#upgrade
RUN apt-get upgrade -y

#install additional packages
RUN apt install gpg-agent -y unixodbc apt-utils curl

#get msodbcsql17 and install it
 RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
 RUN curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
 RUN apt-get update -y
 RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 


RUN apt-get install tcl8.6 tk8.6 -y
#RUN curl -o Rtools.exe https://cran.r-project.org/bin/windows/Rtools/Rtools35.exe
#rename SQL Driver title in odbcinst file
RUN sed -i 's/ODBC Driver 17 for SQL Server/SQL Server/' etc/odbcinst.ini


#install packaes needed for running the app
RUN R -e "install.packages(c('shiny'))"
RUN R -e "install.packages(c('shinydashboard'))"
RUN R -e "install.packages(c('dbplyr'))"
RUN R -e "install.packages(c('odbc'))"
RUN R -e "install.packages(c('sqldf'))"
RUN R -e "install.packages(c('gsubfn'))"
RUN R -e "install.packages(c('proto'))"
RUN R -e "install.packages(c('randomForest'))"
RUN R -e "install.packages(c('plotly'))"
RUN R -e "install.packages(c('DT'))"
RUN R -e "install.packages(c('plyr','dplyr'))"
RUN R -e "install.packages(c('data.table'))"
RUN R -e "install.packages(c('tidyr'))"
RUN R -e "install.packages(c('lubridate'))"
RUN R -e "install.packages(c('shinycssloaders'))"
RUN R -e "install.packages(c('shinyjs'))"
RUN R -e "install.packages(c('stringr'))"
RUN R -e "install.packages(c('stringi'))"
RUN R -e "install.packages(c('shinyFiles'))"
RUN R -e "install.packages(c('DBI'))"
RUN R -e "install.packages(c('readxl'))"
RUN R -e "install.packages(c('installr'))"
RUN R -e "install.packages(c('smbinning'))"

#copy app to image
COPY app/ srv/shiny-server/app

COPY shiny-server.conf/ etc/shiny-server/shiny-server.conf

如果我遗漏了什么,请告知。非常感谢。

解决方法

我在使用 Docker 在优秀的 DigitalOcean 应用程序服务上部署闪亮的应用程序时遇到了类似的问题。我使用的解决方法是强制应用程序每 10 秒在后台执行一些操作。这样做的缺点是它可能永远不会超时......但这应该根据DO应用程序是短暂的这一事实进行排序,因此不活动的会话应该结束(我认为......)

(我从 SO 上的其他地方借用了此代码,不记得在哪里)

在 server.R 的底部...

  #Stop the app timing out
  autoInvalidate <- reactiveTimer(10000)
  observe({
    autoInvalidate()
    cat(".")
  })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-