Open blairj09 opened 4 years ago
This is a non-R auto reload process. BUT, it looks like it works (untested).
A live-reload feature would be very nice to have!
I tried to do some tests, with drip installed in the rstudio/plumber container. I tried using one of the existing bundled examples in the plumber R package that has an entrypoint.R (the example with a counter). It seems drip expects the entrypoint.R to do pr$run() - which seems to clash with the example I was using. I tried just to add that and then got it to run. A couple of reflections from testing this setup (container with latest version of drip + plumber) can be found here: https://github.com/mskyttner/plumber-dripdrop
Another variant https://github.com/mskyttner/trickler is using the official plumber container but extends it with inotify-tools which is used to monitor a directory (mounted from the host) with plumber files. A bash script reloads the server automatically when there are changes made to files mounted in the directory. Tested briefly and seems to resolve some issues I had with drip and later versions of plumber (like "createTcpServer: address already in use" on some restarts and dealing with entrypoint.R-files which return a (not running) plumber router object).
What currently works quite well for me is using entr with something like the following: ls plumber/*.R | entr -r Rscript plumber/entrypoint.R
and just putting that in a Makefile for convenience. Here is good overview for various file watchers, which can also be used: https://anarc.at/blog/2019-11-20-file-monitoring-tools/
Shiny has an option called
shiny.autoreload
that monitors source files for changes and automatically reloads the Shiny app. It would be nice if Plumber had a similar option.