解决shinyapps.io“与服务器断开连接”/“内存不足”问题

时间:2017-12-21 23:09:00

标签: r shiny

我有点困惑。我有一个闪亮的应用程序,在传单底图上显示栅格。您选择9个栅格中的一个,它显示...简单。它在本地工作,需要35秒才能加载。我已经将它部署到shinyapps.io而没有任何警告。我上传的捆绑包大约是8.5MB。当我从他们的服务器运行应用程序时,它会在90秒后停止并显示“与服务器断开连接”。性能日志说“内存不足!”。我怀疑我加载的光栅太大,因为它应该允许高达1GB的免费帐户。基于此处的推荐

Disconnected from Server in shinyapps, but local's working

我尝试了“设置 - >高级 - >启动超时”并将其设置为300秒。仍然是同样的问题。有什么我想念的吗?

R代码

library(raster)
library(rgdal)
library(leaflet)
library(shiny)
library(ggplot2)
library(shiny)
#setwd("E:/Projects/Shiny/ShinyCRP")


ui<-fluidPage(
  titlePanel("Population cores (top 25, 50, 75, 100) **App in development**"),
  sidebarLayout(
    sidebarPanel(width=3, p("Select a bird please."),
                 selectInput(inputId="bird", 
                             label="Birds",
                             c("Baird's Sparrow"="./www/BAIS.tif",
                               "Bobolink"="./www/BOBO.tif",
                               "Chestnut-collared Longspur"="./www/CCLO.tif",
                               "Dickcissel"='"./www/DICK.tif"',
                               "Grasshopper Sparrow"="./www/GRSP.tif",
                               "Lark Bunting"="./www/LARB.tif",
                               "Ring-necked Pheasant"="./www/RNEP.tif",
                               "Sedge Wren"="./www/SEWR.tif",
                               "Sprague's Pipit"="./www/SPPI.tif"))),
    mainPanel(
      tabsetPanel(
        tabPanel("Plot", p("The data presented in these maps are population cores of density
                           and distribution models." ),
                 leafletOutput("MapPlot1")),
        tabPanel("Summary", p("Working on this"),
                 fluidRow(
                   column(3, tableOutput(outputId="summary")),
                   column(3, tableOutput(outputId="summary1")),
                   column(6, plotOutput(outputId="summary2"))))
      )
    )
  )
)

server <- function(input, output, session) {
  output$MapPlot1 <- renderLeaflet({
    bird<-raster(input$bird)
    pal <- colorNumeric(c("#022051", "#00ff8c", "#ffc700", "#ff3700"), values(bird),
                        na.color = "transparent")
    wmcrs <- "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs"
    bird<-raster::projectRaster(
      bird, raster::projectExtent(bird, crs = sp::CRS(wmcrs)),
      method = "ngb")
    bird<-raster::as.factor(bird)
    leaflet() %>% addTiles() %>%
      addProviderTiles(providers$Esri.WorldImagery)%>%
      addProviderTiles(providers$Stamen.TonerHybrid,
                       options = providerTileOptions(opacity = 0.7))%>%
      addRasterImage(bird, project=FALSE, colors = pal, opacity = 0.4);
      })
}

shinyApp(ui=ui, server=server)

效果日志

2017-12-21T22:53:31.607046+00:00 shinyapps[251024]: Loading required package: sp
2017-12-21T22:53:32.431346+00:00 shinyapps[251024]: rgdal: version: 1.2-13, (SVN revision 686)
2017-12-21T22:53:32.431350+00:00 shinyapps[251024]:  Geospatial Data Abstraction Library extensions to R successfully loaded
2017-12-21T22:53:32.674556+00:00 shinyapps[251024]: 
2017-12-21T22:53:32.431352+00:00 shinyapps[251024]:  Loaded GDAL runtime: GDAL 2.1.0, released 2016/04/25
2017-12-21T22:53:32.431353+00:00 shinyapps[251024]:  Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
2017-12-21T22:53:32.431352+00:00 shinyapps[251024]:  Path to GDAL shared files: /usr/share/gdal/2.1
2017-12-21T22:53:32.431354+00:00 shinyapps[251024]:  Path to PROJ.4 shared files: (autodetected)
2017-12-21T22:53:32.431355+00:00 shinyapps[251024]:  Linking to sp version: 1.2-5 
2017-12-21T22:53:32.674572+00:00 shinyapps[251024]: Listening on http://127.0.0.1:33580
2017-12-21T22:55:11.813279+00:00 shinyapps[system]: Out of memory! 

编辑:与内存相关的应用程序指标。不确定第二张照片中的单位是什么。 enter image description here enter image description here

0 个答案:

没有答案