I've been working on a Shiny app and locally it works fine, it displays my graphs and lets me twitch the widgets. I have 3 csv files hosted in the data folder, that is placed where my app.R and fc_auxiliares.R files are. I have a shinyapp.io account and check I upload everything when publishing, both the .R files and the data folder.
One of the datasets weights 160MB, the other two a hundred KBs each.
The trouble is I get the message "An error has occurred The application failed to start. exit status 1" when deploying, using shinyapps.io.
I don't know why this rises. Any help would be greatly appreciated.
Here is the code, simplified all the text in the UI.
# Package names
x <-c('shinydashboard','flexdashboard','shinyWidgets', 'shinythemes', 'shinyjs', 'thematic', 'glue', 'ggplot2', 'stringr',
'connectapi', 'tidyverse', 'RColorBrewer', 'raster', 'ggmap', 'wordcloud2', 'maps', 'geosphere', 'ggmap',
'dplyr', 'plotly', 'sp', 'viridis')
# Install packages not yet installed
installed_packages <- x %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
install.packages(x[!installed_packages])
}
# Packages loading
invisible(lapply(x, library, character.only = TRUE))
#Load data
datos = read.csv('./data/data_aeropuertos.csv')
datos$mes_name <- factor(datos$mes_name, levels=c('Ene', 'Feb','Mar','Abr','May','Jun','Jul','Ago','Sep','Oct','Nov','Dic'))
datos$fecha_datetime <- factor(datos$fecha_datetime, levels=c('Lun','Mar','Mie','Jue','Vie','Sab','Dom'))
aeropuertos = read.csv('./data/aeropuertos_detalle.csv', sep=';')
library(geojsonio)
provincias <- geojson_read("./data/provincias.json", what = "sp")
#Helper functions 2 plot
source('fc_auxiliares.R')
ui <- fluidPage(theme = shinytheme("readable"),
titlePanel(h1("...", align="center")),
fluidRow(width=12, style = "background-color: #95c2c9; padding: 10px",
h5('...'),
p('....') ),
# #------------------------------------------------------------------------------------------------------------
fluidRow(width=12,style = "background-color: #badbe0; padding: 20px ",
# h5('..'),
p("...."),
),
# #------------------------------------------------------------------------------------------------------------
fluidRow(align='left',style="text-align: justify;",
column(width = 6,
plotlyOutput('VUELOS.X.ANIO')),
column(width = 6, h3('...'),
p(".....")
) ),
# #------------------------------------------------------------------------------------------------------------
fluidRow(style = "border: 4px double blue;",align='center',style="text-align: justify;",
column(width = 6, h3('....'),
p(".."),
),
column(width = 6,align='center',
radioGroupButtons(inputId = "radio_vuelos_mes",
label = "",
choices = c('Todos', 'Domestico', 'Internacional'),
selected = 'Todos',
status = "success"),
plotlyOutput('VUELOS.MES')
) ),
# #------------------------------------------------------------------------------------------------------------
fluidRow(align='center',style="text-align: justify;",
column(width = 8,align='center',
radioGroupButtons(inputId = "radio_vuelos_semanal",
label = "",
choices = c('Todos', '2019', '2020','2021', '2022','2023'),
selected = 'Todos',
status = "info"),
plotlyOutput('VUELOS.SEMANAL')
),
column(width = 4, align='center',style="text-align: justify;",
h3('....'),
p("....")
) ) ,
# #------------------------------------------------------------------------------------------------------------
fluidRow(style = "border: 4px double blue;",align='center',style="text-align: justify;",
column(width = 3,h3("....."),
p(".......")
),
column(width = 9, align='center',
radioGroupButtons(inputId = "radio_promDiario",
label = "",
choices = c('Todos', 'Domestico', 'Internacional'),
selected = 'Todos',
status = "success"),
plotlyOutput('PROM.DIARIO')
) ),
#------------------------------------------------------------------------------------------------------------
fluidRow(align='center',style="text-align: justify;",
column(width = 8, align='center',
radioGroupButtons(inputId = "radio_empresas",
label = "",
choices = c('Todos', '2019', '2020','2021', '2022','2023'),
selected = 'Todos',
status = "info"),
plotlyOutput('TOP.EMPRESAS')
),
column(width =4, h3('.....'),
p("....")
) ),
#------------------------------------------------------------------------------------------------------------
fluidRow(style = "border: 4px double blue;",align='center',style="text-align: justify;",
column(width = 4, h3('......'),
p("....."),
p("....")
),
column(width = 8,align='center',
radioGroupButtons(inputId = "radio_par_ori_dest",
label = "",
choices = c('Todos', '2019', '2020','2021', '2022','2023'),
selected = 'Todos',
status = "info"),
plotlyOutput('ORI.DEST'))
),
#------------------------------------------------------------------------------------------------------------
fluidRow(align='center',style="text-align: justify;",
column(width = 6, align = "center",
plotlyOutput('MAPITA')
),
column(width=6, align='center', style="text-align: justify;",
h3('......'),
p("......"),
radioGroupButtons(inputId = "rd_mapa",
label = "",
choices = c('Todos', '2019', '2020','2021', '2022','2023'),
selected = 'Todos',
status = "info"),
sliderInput("slider_mapa", "Seleccionar rango de número de vuelos anuales",
min = 0, max = 1100, value = c(300, 500))
)),
)
server <- function(input, output) {
# NRO VUELOS X ANIO
output$VUELOS.X.ANIO = renderPlotly({ despegues_x_anio(datos) })
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# NRO VUELOS X MES
anio_vuelos_x_mes = reactive({ input$radio_vuelos_mes }) #Obtengo el chbox elegido; luego accedo a el usando anio_vuelos_x_mes()
output$VUELOS.MES= renderPlotly({vuelos_mensuales(datos , anio_vuelos_x_mes() ) }) #Ejecuto la fc para plotear el grafico
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# VUELOS X DIA DE LA SEMANA
anio_vuelo_semanal = reactive ({ input$ radio_vuelos_semanal})
output$VUELOS.SEMANAL = renderPlotly({vuelos_semanales(datos , anio_vuelo_semanal() ) })
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# PROMEDIO DIARIO DE VUELOS
tipo_vuelo_promDiario = reactive ({ input$radio_promDiario})
output$PROM.DIARIO = renderPlotly({promedio_dia(datos, tipo_vuelo_promDiario() ) })
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# TOP EMRPESAS
aerol = reactive ({ input$radio_empresas})
output$TOP.EMPRESAS = renderPlotly({airlines(datos, aerol() ) })
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
# PARES ORIGEN-DESTINO
rd_ori_dest = reactive ({ input$radio_par_ori_dest})
output$ORI.DEST = renderPlotly({pair_airports(datos , rd_ori_dest() ) })
# ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
radio_map = reactive ({ input$rd_mapa})
limInf = reactive({input$slider_mapa[1]})
limSup = reactive({input$slider_mapa[2]})
output$MAPITA = renderPlotly({plot_mapa(provincias, datos , aeropuertos , radio_map(), limInf(), limSup() ) })
}
shinyApp(ui = ui, server = server)
This is the log I get:
2023-07-26T00:51:38.019300+00:00 shinyapps[9508974]: Content will use current R environment
2023-07-26T00:51:38.019305+00:00 shinyapps[9508974]: R_LIBS: (unset)
2023-07-26T00:51:38.019326+00:00 shinyapps[9508974]: .libPaths(): /opt/R/4.3.1/lib/R/library
2023-07-26T00:51:38.024980+00:00 shinyapps[9508974]: shiny version: 1.7.4.1
2023-07-26T00:51:38.024991+00:00 shinyapps[9508974]: httpuv version: 1.6.11
2023-07-26T00:51:38.025001+00:00 shinyapps[9508974]: rmarkdown version: (none)
2023-07-26T00:51:38.025006+00:00 shinyapps[9508974]: knitr version: (none)
2023-07-26T00:51:38.025044+00:00 shinyapps[9508974]: jsonlite version: 1.8.5
2023-07-26T00:51:38.025055+00:00 shinyapps[9508974]: RJSONIO version: (none)
2023-07-26T00:51:38.025060+00:00 shinyapps[9508974]: htmltools version: 0.5.5
2023-07-26T00:51:38.025076+00:00 shinyapps[9508974]: reticulate version: (none)
2023-07-26T00:51:38.025207+00:00 shinyapps[9508974]: Using pandoc: /opt/connect/ext/pandoc/2.16
2023-07-26T00:51:38.422480+00:00 shinyapps[9508974]: Starting R with process ID: '34'
2023-07-26T00:51:38.422889+00:00 shinyapps[9508974]: Shiny application starting ...
2023-07-26T00:51:38.643293+00:00 shinyapps[9508974]: Warning in install.packages(x[!installed_packages]) :
2023-07-26T00:51:38.643333+00:00 shinyapps[9508974]: 'lib = "/opt/R/4.3.1/lib/R/library"' is not writable
2023-07-26T00:51:38.688922+00:00 shinyapps[9508974]: Error in install.packages(x[!installed_packages]) :
2023-07-26T00:51:38.688966+00:00 shinyapps[9508974]: unable to install packages
2023-07-26T00:51:38.688971+00:00 shinyapps[9508974]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
2023-07-26T00:51:38.688975+00:00 shinyapps[9508974]: Execution halted
2023-07-26T00:51:38.688980+00:00 shinyapps[9508974]: Shiny application exiting ...
2023-07-26T00:51:40.722843+00:00 shinyapps[9508974]: Running on host: 3bdeb9c8ed40
2023-07-26T00:51:40.725578+00:00 shinyapps[9508974]: Running as user: uid=10001(shiny) gid=10001(shiny) groups=10001(shiny)
2023-07-26T00:51:40.725603+00:00 shinyapps[9508974]: Connect version: 2023.03.0
2023-07-26T00:51:40.725608+00:00 shinyapps[9508974]: LANG: C.UTF-8
2023-07-26T00:51:40.725612+00:00 shinyapps[9508974]: Working directory: /srv/connect/apps/trafico_aereo_argentina
2023-07-26T00:51:40.725801+00:00 shinyapps[9508974]: Using R 4.3.1
2023-07-26T00:51:40.725826+00:00 shinyapps[9508974]: R.home(): /opt/R/4.3.1/lib/R
2023-07-26T00:51:40.726155+00:00 shinyapps[9508974]: Content will use current R environment
2023-07-26T00:51:40.726186+00:00 shinyapps[9508974]: R_LIBS: (unset)
2023-07-26T00:51:40.726194+00:00 shinyapps[9508974]: .libPaths(): /opt/R/4.3.1/lib/R/library
2023-07-26T00:51:40.730866+00:00 shinyapps[9508974]: shiny version: 1.7.4.1
2023-07-26T00:51:40.730883+00:00 shinyapps[9508974]: httpuv version: 1.6.11
2023-07-26T00:51:40.730887+00:00 shinyapps[9508974]: rmarkdown version: (none)
2023-07-26T00:51:40.730891+00:00 shinyapps[9508974]: knitr version: (none)
2023-07-26T00:51:40.730898+00:00 shinyapps[9508974]: jsonlite version: 1.8.5
2023-07-26T00:51:40.730909+00:00 shinyapps[9508974]: RJSONIO version: (none)
2023-07-26T00:51:40.730927+00:00 shinyapps[9508974]: htmltools version: 0.5.5
2023-07-26T00:51:40.730941+00:00 shinyapps[9508974]: reticulate version: (none)
2023-07-26T00:51:40.731087+00:00 shinyapps[9508974]: Using pandoc: /opt/connect/ext/pandoc/2.16
2023-07-26T00:51:41.114185+00:00 shinyapps[9508974]: Starting R with process ID: '53'
2023-07-26T00:51:41.114570+00:00 shinyapps[9508974]: Shiny application starting ...
2023-07-26T00:51:41.185987+00:00 shinyapps[9508974]: Warning in install.packages(x[!installed_packages]) :
2023-07-26T00:51:41.186023+00:00 shinyapps[9508974]: 'lib = "/opt/R/4.3.1/lib/R/library"' is not writable
2023-07-26T00:51:41.245099+00:00 shinyapps[9508974]: Error in install.packages(x[!installed_packages]) :
2023-07-26T00:51:41.245128+00:00 shinyapps[9508974]: unable to install packages
2023-07-26T00:51:41.245136+00:00 shinyapps[9508974]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
2023-07-26T00:51:41.245142+00:00 shinyapps[9508974]: Execution halted
2023-07-26T00:51:41.245150+00:00 shinyapps[9508974]: Shiny application exiting ...
2023-07-26T01:06:42.557234+00:00 shinyapps[9508974]: Container event from container-8434200: stop
The "exit status 1" error in Shiny apps on shinyapps.io can occur due to various reasons. The most common issues are related to resource limitations, file size restrictions, or package dependencies.
In your case, the first thing which comes to my mind is the fact that you upload a 160 MB file without, at least not from what I could find, changing the maximum upload size.
The default for that is 5 MB, so in your case this snippet at the beginning of the server should fix the issue if it is indeed a problem with the size limit.
If you want a different file size, just change the first value in the term, or, if you want a little bit of wiggle room, just do 200 or something. Let me know if this helps. ;)