I have a Dockerized R Shiny app that extends the rocker/shiny image. I would like to restart the shiny-server inside of the Docker container at some point. From the documentation of shiny-server, I tried all the commands for different Linux builds and none of them worked.
Does anyone know how to restart the shiny-server in the Docker container?
The command
docker ps
lists all running containers, get the required container id. Then run
docker exec -it <container_id> bash
to get into the required docker container. Then
sudo -i
sudo systemctl restart shiny-server
to restart the shiny server. Hope that helps, systemctl will probably only work on Ubuntu.
An app running in shiny server can be restarted by updating the timestamp on a file restart.txt
.
From the docs:
An application can be restarted by altering the "modified time" on a file named
restart.txt
in the application's directory. This can most easily be done using thetouch
utility, as intouch restart.txt
, which will update the modified timestamp on this file to the current time. Upon the next new connection to the application, Shiny Server will spawn a new R process to run the "new" (restarted) Shiny Application for this and future users.
(Source: https://docs.rstudio.com/shiny-server/#restarting-an-application)
If you need to periodically restart the application (eg. if you set app_idle_timeout = 0
but wish to regularly restart to pull some updated data), you could use a cronjob in the rocker/shiny
container to touch restart.txt
according to some desired schedule.
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