rocker-org / rocker-versioned

Run current & prior versions of R using docker
https://hub.docker.com/r/rocker/r-ver
GNU General Public License v2.0
297 stars 169 forks source link

How to know when rstudio-server is up and running? #100

Closed kimwalisch closed 6 years ago

kimwalisch commented 6 years ago

Hi,

First of all thanks for this amazing project! I have written a backend program which starts a rocker rstudio container and then waits for 3 seconds (in order to ensure that the rstudio-server is up and running). After the 3 seconds timeout the backend maps the port of the rocker rstudio container to a URL (by configuring the Apache web-server) and then opens RStudio in the user's browser.

Instead of waiting for a fixed period of 3 seconds I would like to change my backend program to get notified (or periodically check) when the rstudio-server is up and running in the Docker container. And once the backend gets the confirmation that the rstudio-server is up and running it can configure Apache and open RStudio in the user's web-browser. The benefit of this approach would be faster startup times of RStudio web sessions for my users.

cboettig commented 6 years ago

Great question, thanks for getting in touch.

Best thing I think is to check the docker logs. (see e.g. docker logs -h) You should see something like:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] 01-userconf: executing... 
Skipping authentication as requested
[cont-init.d] 01-userconf: exited 0.
[cont-init.d] add: executing... 
Nothing additional to add
[cont-init.d] add: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.

Once it reaches the last line there, [services.d] done, that indicates that RStudio server should now be up and running.

kimwalisch commented 6 years ago

Thanks for your answer.

I have now implemented another method in my backend program for checking if the rstudio-server is up an running. After the backend program has started up a new rstudio docker container it spins up a new thread which notifies the backend program once it has successfully connected to the container's rstudio port. Upon notification (from the thread) the backend program opens RStudio in the user's browser.

This approach works well for me and was easier to implement than parsing the docker logs in order to figure out when rstudio-server has finished its startup.