Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R shiny: How to allow users to stop the process? And how to stop the app from backend?

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

like image 654
cloudy Avatar asked Oct 28 '14 03:10

cloudy


People also ask

How do you stop a Shiny app?

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.

What does REQ () do in R?

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.

What are the main 2 parts of an R Shiny app?

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.


1 Answers

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.

like image 142
kgui Avatar answered Sep 23 '22 18:09

kgui