Open SanthoshManikantan opened 1 year ago
I've encountered the same issue and hope to find a solution!
Why do you need to call stopApp()
? stopApp()
is useful in local to free the R session but has no interest afaik on a server
such as using shinymanager with DesktopDeployR(A framework for deploying self-contained R-based applications to the desktop), session$onSessionEnded(function() {stopApp()})
IMPORTANT! this is needed to terminate the R process when the shiny app session ends. Otherwise, you end up with a zombie process
I have an application which uses the shinymanager library for user login. I want to use the session$onSessionEnded() to close my app once the browser is closed. As suggested by @ismirsehregal here shinymanager with onsessioneneded() the workaround is working fine for the login but if we logout or going to administrator mode (while using db) the app is getting stopped. Could you please provide a workaround for this. samplecode
`library(shiny) library(shinyWidgets) library(shinythemes) library(shinymanager)
credentials <- data.frame( user = c("admin", "shinymanager"), # mandatory password = c("admin", "12345"), # mandatory start = c("2022-04-15"), # optinal (all others) expire = c(NA, "2026-12-31"), admin = c(TRUE, TRUE), comment = "Simple and secure authentification mechanism for single ‘Shiny’ applications.", stringsAsFactors = FALSE )
ui <- fluidPage( sliderInput("n", "Number of observations", 2, 1000, 500), plotOutput("plot") )
ui <- secure_app(ui)
server <- function(input, output, session) { res_auth <- secure_server( check_credentials = check_credentials(credentials) )
session$onSessionEnded(function() { print(paste("Session", session$token, "ended")) if(!is.null(isolate({res_auth$user}))){ stopApp() } })
observe({
Re-execute this reactive expression after 1000 milliseconds
}) output$plot <- renderPlot({
Re-execute this reactive expression after 2000 milliseconds
}) }
shinyApp(ui, server)`