2

we have created a Shiny App which is deployed on shinyapp.io. we are trying to reload the data on shinyapp.io in every 1 hour by using invalidateLater but it is not working when the application is closed/browser closed. we have heard about cronR but unable to use it through windows system(deploying the app from windows to shinyapp.io). cronR package is not being installed while deploying on shinyapp.io

In below code, We are trying to ping the database, and checks last ETL updated date with last data stored date if the time is greater then last data stored time then it will call the data_refresshing() function and it will reload the app.

observe({
   invalidateLater(300000, session = session)
   myRedshift <- src_postgres('dfdbwh',
                              host = 'xxxxxxxxxxxxxxxxxxxxxxx',
                              port = 1234,
                              user = "xxxxxxxx",
                              password = "xxxxxxxxxx")
   data <- tbl(myRedshift, "MAX_ETLINCR_DATE_V")
   t <- data %>% select(maxdate)
   temp <- as.data.table(t)
   last_ETL_updated_date_time <- temp$maxdate
   last_updated_date_time <- readRDS("last_updated_date_time.rds")
   if(last_updated_date_time < last_ETL_updated_date_time)
   {
     data_refreshing()
     js$reload()
   }

   if(file.exists("Trigger_time.rds") == FALSE)
   {
     Trigger_time <- c(Trigger_time,paste0(now(tz="Asia/Kolkata")))
     saveRDS(Trigger_time,file = "Trigger_time.rds")
   }
   else
   {
     Trigger_time <- readRDS("Trigger_time.rds")
     Trigger_time <- c(Trigger_time,paste0(now(tz="Asia/Kolkata")))
     saveRDS(Trigger_time,file = "Trigger_time.rds")
   }
   })
  • 1
    See here for a suggestion: https://community.rstudio.com/t/using-cron-to-import-data-daily-and-update-shiny-app/24217/5. Or possible duplicate: https://stackoverflow.com/questions/40690132/cron-job-in-r-shiny-shiny-task-schedule-in-shinyapps-io. But you are unlikely to be able to do this with shinyapps. You'd likely have to set up your own shiny server if you required that functionality. – MrFlick Apr 15 '19 at 15:09
  • @MrFlick Thanks for your very quick response, we need to do this on shinyapp.io as we purchased shinyapp.io subscription. is there any way to install packages on the cloud(shinyapp.io) when needed? – Basant Neupane Apr 16 '19 at 05:08
  • If you need support for shinyapps, then I suggest you request help at https://community.rstudio.com instead of Stack Overflow. – MrFlick Apr 16 '19 at 14:39

0 Answers0