I have a shiny app that allows users to upload their own data and do a few tasks. Depending on their data size and the type of tasks they would want to perform, sometimes the process gets long and even lasting forever. I would like to add the "stop" function in which users can click on it and the current task will stop and they can continue to some other tasks. How should I do it?
My second question is related to the first one. Say one of my app users has deployed a very heavy process and it has heavily occupied my CPU but the user himself has not initiated the stop signal. I would like to impose a "time out" command so that the app will be automatically terminated say after 5 minutes. How can I set it up?
Many thanks and best regards,
cloudy
Automatically stop a Shiny app when closing the browser tabBy adding a single line to the server code session$onSessionEnded(stopApp) , a Shiny app will automatically stop running whenever the browser tab (or any session) is closed.
req is short for “require”, so req(x) can be read as either “require x to be available”. You call req with one or more arguments. req will evaluate each argument one at a time, and if it encounters an argument that it considers to be “missing” or “false” (see below for exactly what this means), it will stop.
A Shiny app consists of two parts, a user interface ( ui ) and an R session that runs code and returns results ( server ). These two parts can be in their own files called ui. R and server. R, or they can be combined into a single file called app.
I would create an action button that has a "Cancel" label but, will redirect to a new page when clicked on.
actionButton("button", "Cancel Operation")
In regards to the CPU stop limit, I would create a timer for that action button and when it's clicked the timer starts. Then test if a conditional statement (the time limit) has passed, redirect to a new page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With