For instance, my shiny app might open a DB connection
# server.R
db <- dbConnect("SQLite", DB_PATH)
shinyServer(
... # things involving db
)
Now, how to ensure that the connection db
is closed properly (via dbDisconnect(db)
) when the Shiny session ends? Indeed, should cleanup be performed for each client that connects to the server, or just once?
I simply fear that with multiple users connecting and disconnecting to the Shiny app all the time, they'll leave dangling DB connections if not properly cleaned up. Indeed, clients may disconnect without warning simply by closing their browsers.