如何授予 R Shiny Server 在 Ubuntu 上渲染 Rmarkdown 的权限?

问题描述 投票:0回答:1

我有一个 R Shiny 应用程序在 EC2 实例上的 Shiny Server 上运行。操作系统是Ubuntu。应用程序通过 GitHub Actions 和 CodeDeploy 从 GitHub 推送到 EC2 实例。

除了运行

shiny::downloadHandler
生成可供用户下载的 Word 文档的
rmarkdown::render
之外,该应用程序也能正常工作。

在我正在开发的机器上本地渲染和下载它没有问题。

但是,当应用程序在 EC2 实例上运行时按下下载按钮时,会打开一个新选项卡,但没有可供下载的文档。闪亮的日志状态:

processing file: report_template.qmd
Warning in file(con, "w") :
  cannot open file 'report_template.knit.md': Permission denied
Warning: Error in file: cannot open the connection
  1: runApp [/tmp/RtmpLLsUwv/R.INSTALLf0c038efa14b/shiny/R/runapp.R#388]

我已更改包含应用程序的

shiny-server
目录的文件权限,但我认为这不起作用,因为我相信权限错误一定位于临时文件中。

我也尝试了以下方法,但没有成功: https://deanattali.com/2015/05/09/setup-rstudio-shiny-server-digital-ocean/#shiny-user-perms

我还需要做些什么才能为用户

shiny
提供正确的权限吗?

r ubuntu amazon-ec2 shiny shiny-server
1个回答
0
投票

我遇到了这个问题,我相信这是由于中间目录没有权限造成的(正如您也发现的那样)。我通过根据临时文件位置设置中间目录来解决这个问题。

这是我从下载处理程序中获取内容函数的方法:

  content = function(file){
    #use temp folder as intermediates directory to ensure permissions are available for the folder
    splitFile <- unlist(strsplit(file,'/'))
    intDir <- paste(splitFile[1:(length(splitFile)-1)], collapse = '/')
    
    #create report based on template
    res <- rmarkdown::render(
      "report.Rmd",
      output_file = file,
      intermediates_dir = intDir
    )
  }
© www.soinside.com 2019 - 2024. All rights reserved.