How to spawn a long-running R parallel process in background that runs an R script from a shiny app?


I have a shiny application that collects some parameters from users, which will then be used to run a simulation, which takes a long time ~ 1-3 days. So, I want the ability to tell the user to check back when the simulation is solved, as well as provide the capability to submit more input scenarios. So I want to spawn a subprocess to perform the simulation in the background, while my shiny app runs.

I tried the package 'subprocess' and 'processx', which allows one to spawn external processes and interact with them. However, I want the ability to run an entire R script with the spawned process. i.e. run source('simulation_script.R'). Also, I do not care if I am not able to share any data with my parent shiny app. I read inputs from files and write outputs to files, which can then be shown to the shiny app user. Any pointers to achieve this would be helpful?


Maybe this could help:

Keep us posted!

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.