Shiny R: Updating global environment objects from a batch file on a server application? - r

I have a shiny app that continuously runs on a server, but this app uses SQL data tables and needs to check for updates once a day. Right now, with no batch file in place, I have to manually stop the app, run an R script that checks for these updates, then re-run the app. The objects that I want to update are currently stored in RStudio's global environment. I've been looking around at modifying .RData files because I'm running out of options. Any ideas?
EDIT: I'm aware that I probably have to shut down the app for a few minutes to refresh the tables, but is there a way I can do something like this using a batch file?

Related

Automatically restart Shiny apps after server reboot

I have a Shiny application that needs to load into memory some fairly large data sets. To save the users some time when browsing to the dashboard, I set the app_idle_timeout to zero (using the community version of the Shiny server application), as suggested in the docs. This works as expected.
However, the underlying data needs to be refreshed daily. Hence, what I would like to do is setting up a cron job that reboots the shiny server (or stops the relevant sessions) every day at 3am and then automatically initiates a new R session so that the data in the global.R is loaded into memory and the dashboard ready to consume instantly.
What I do not understand is how to initiate a particular Shiny application from terminal, i.e. mimic what happens when browsing to the URL of this app on the Shiny server.
Any suggestion would be greatly appreciated.

Shiny reconnecting to existing session

I created a Shiny app which is doing a long computation and therefore i am running it on a local server in my Network.
I can access the app via my computer, upload files and start the calculation. But when I close the browser and access the app via a weblink again, Shiny will start a new empty session.
How can I reconnect to the "closed" session with the hopefully still running computation and uploaded files?
It seems that it may be possible with RStudio Connect or running the app via a ShinyServer. Is there another easy way to handle it?
Reconnecting to the exact same session seems not possible. I found after a lot of research the Bookmark function, which saves your Input inside a new URL or on a Server. See references here: Link
Unfortunately, it didnt work really good because i had bigger plots and tables as saved output.
I solved the problem with a workaround. In the end of the computation i save the whole environment with save.image(file='myEnvironment.RData')
I added an actionbutton and by clicking it loads the saved environment with load('myEnvironment.RData'). After this, all files are back in the environment and new outputs can be created by e.g. output$xy <- renderPlot({XY}).
Hope that helps

How to run R scripts on server from web interface

There are a few R scripts that several analysts in an organization need to use in their daily life in order to get some analysis and reports.
I was planning to create a Shiny app so that the scripts would be able to run on a server with more memory and processing power, as well as for having some validation of the inputs with selectable or dropdown fields, as now the inputs are typed manually and this creates a lot of errors.
But there are a few problems with this approach (as far as I know):
1) Shiny disconnects when users closes browser or connection, what would finish the execution of the scripts (they can take several hours to run)
2) Once a script is launched it blocks the whole Shiny for doing other tasks (I have unsuccessfully tried to set up parallel computing... we have Windows servers).
Are there any solutions for the issues above to keep on using Shiny?
Maybe Shiny is not the best system for this? Are there any alternatives?
Thanks
I can't tell you for shiny, but in general there are 2 tools I can recommend for it: rundeck and script-server. Both of them can execute any type of scripts and provide web UI for the script with required inputs, script output, logging, etc.
disclaimer: I'm the owner of the script-server project

Deploy Shiny app that can read files from local computer (no possible Data-based solution)

I am trying to deploy a Shiny app on shinyapps, but it is not possible to read and write local files from the computer of the user. The idea is that every user can upload some datasets and images given a local path where this input is stored, not to have a same series of inputs for everyone stored in a ´Data´ folder.
I know there are other options to deploy shiny apps (amazon, shiny server), but I am afraid I will find the same kind of problems. Before losing too much time trying other approaches, I would like to know if there is any way to deploy a shiny app that can read these inputs given a local path and, if not, if there is an easy way to prepare an online app that can do this trasnlating from a shiny-based one. If not, I guess I will have to leave my app as a normal R package.
Thank you in advance.

R shiny concurrent file access

I am using the R shiny package to build a web interface for my executable program. The web interface provides user input and shows output.
On the server background, the R script formats user inputs and saves them to a local input file. Then R calls the system command to run the executable program.
My concern is that if multiple users run the web app at the same time, it is possible that the input file generated by the first user will be overwritten by the second user's input before it is read by the executable program.
One way to solve the conflict is to ask R to create a temporary folder and generate/run the input file under that folder for each user. But I'd like to know whether there is a better or automatic way to resolve this potential conflict with shiny. For example, if use shiny fileInputs, the uploaded files are automatically stored in a temporary folder.
Update
Thanks for the advice.#Symbolix and #Mike Wise
I read the persistent data storage article before but I don't think it is exactly what I wanted. Maybe my understanding is not correct. I end up with creating a temporary folder and run my executable from there.

Resources