在 shiny-server 上使用来自 shinylogs 的 store_json() 的问题

Problems using store_json() from shinylogs on shiny-server

我正在尝试在 Ubuntu 20.04 上部署一个使用 shinylogs store_json() 函数的 shiny-server 运行 的 shiny 应用程序。但是,无论我使用哪个路径,它都不会保存文件,并且我的日志中也不会出现错误。

write.table() 一切正常,所以我想知道 shinylogs 是否需要在 shiny-server 上进行任何特殊配置 运行。

我改编了 https://github.com/dreamRs/shinylogs/blob/master/examples/store_json.R 中的最小工作示例。该应用程序已正确执行,我可以使用它,但它不会保存任何日志。

由于我要部署的应用程序不是我写的,我有点依赖使用 shinylogs 所以我非常感谢任何帮助!

  library(shiny)
  library(shinylogs)

  tmp <- "~"

  # Classir Iris clustering with Shiny
  ui <- fluidPage(

    headerPanel("Iris k-means clustering"),

    sidebarLayout(
      sidebarPanel(
        selectInput(
          inputId = "xcol",
          label = "X Variable",
          choices = names(iris)
        ),
        selectInput(
          inputId = "ycol",
          label = "Y Variable",
          choices = names(iris),
          selected = names(iris)[[2]]
        ),
        numericInput(
          inputId = "clusters",
          label = "Cluster count",
          value = 3,
          min = 1,
          max = 9
        )
      ),
      mainPanel(
        plotOutput("plot1")
      )
    )
  )

  server <- function(input, output, session) {

    # Store JSON with logs in the temp dir
    track_usage(
      storage_mode = store_json(path = tmp)
    )

    # classic server logic

    selectedData <- reactive({
      iris[, c(input$xcol, input$ycol)]
    })

    clusters <- reactive({
      kmeans(selectedData(), input$clusters)
    })

    output$plot1 <- renderPlot({
      palette(c("#E41A1C", "#377EB8", "#4DAF4A", "#984EA3",
                "#FF7F00", "#FFFF33", "#A65628", "#F781BF", "#999999"))

      par(mar = c(5.1, 4.1, 0, 1))
      plot(selectedData(),
           col = clusters()$cluster,
           pch = 20, cex = 3)
      points(clusters()$centers, pch = 4, cex = 4, lwd = 4)
    })

  }

  shinyApp(ui, server)

我设法通过简单地包含 library(jsonlite) 来解决这个问题,因为它的 write_json() 函数是由 shinylogs 使用 :: 调用的。我真的没有解释。因此,如果有人知道为什么这会造成问题,请告诉我!