drip
is an easy-to-use development utility that will monitor your Plumber applications for any changes in your source and automatically restart your server.
This project is under development and subject to change. All feedback and issues are welcome. 🍻
The key features of drip are:
- Automatic restarting of Plumber applications on file changes 🚀
- Distributed as a single binary. Install drip by unzipping it and moving it to a directory included in your system's PATH
- Ignore specific directories
- Generate and watch route maps
drip utilizes Rscript to run the Plumber application process. For that reason, R is required for the CLI to correctly execute.
To install drip, find the appropriate package for your system and download it from the download page. drip is packaged as a zip archive.
After downloading drip, unzip the package. drip runs as a single binary named drip. Make sure that the drip binary is available on the PATH.
drip requires that the Plumber application structure make use of an entrypoint.R
that references a plumber.R
app.
# entrypoint.R
plumber::plumb("plumber.R")$run("0.0.0.0", port=8000)
# entrypoint.R
library(plumber)
pr <- plumb("plumber.R")
pr$run("0.0.0.0", port=8000)
Watch the current directory for changes using default option flag parameters.
drip [flags]
drip [command]
Available Commands:
help
Help about any commandroutes
Display all routes in your Plumber applicationversion
Print the version number of dripwatch
Watch the current directory for any changes
Flags:
-h
,--help
help for drip
# cd into project
$ drip
[project-dir] skipping directory: .Rproj.user
[project-dir] skipping directory: node_modules
[project-dir] plumbing...
[project-dir] running: Rscript /project-dir/entrypoint.r
[project-dir] watching...
Starting server to listen on port 8000
[project-dir] modified file: /project-dir/plumber.R
[project-dir] plumbing...
[project-dir] running: Rscript /project-dir/entrypoint.r
[project-dir] watching...
Starting server to listen on port 8000
Watch and rebuild the source if any changes are made across subdirectories
Usage: drip watch [flags]
The list of available flags are:
-d
,--dir
(string) Source directory to watch-e
,--entry
(string) Plumber application entrypoint file (default "entrypoint.r
")-f
,--filter
(string) Filter endpoints by substring match-h
,--help
help for watch--host
(string) Display route endpoints with a specific host (default "127.0.0.1")--port
(int) Display route endpoints with a specific port (default 8000)--routes
Display route map alongside file watcher--showHost
Display absolute route endpoint in output-s
,--skip
(strings) A comma-separated list of directories to not watch. (default [node_modules,.Rproj.user,.git])
# cd into project
$ drip watch --routes
[project-dir] skipping directory: .Rproj.user
[project-dir] skipping directory: node_modules
[project-dir] plumbing...
[project-dir] running: Rscript /project-dir/entrypoint.r
[project-dir] routing...
+--------------+----------------------------+---------------+
| PLUMBER VERB | ENDPOINT | HANDLER |
+--------------+----------------------------+---------------+
| @get | /echo | function |
| @get | /dynamic/<param1>/<param2> | function |
| @get | /two | function |
| @get | /plot | function |
| @post | /sum | function |
| @get | /req | function |
| @assets | ./files/static | static assets |
+--------------+----------------------------+---------------+
[project-dir] watching...
Starting server to listen on port 8000
Or, display routes with an absolute URI and port.
# cd into project
$ drip watch --routes --showHost --host http://localhost
[project-dir] skipping directory: .Rproj.user
[project-dir] skipping directory: node_modules
[project-dir] plumbing...
[project-dir] running: Rscript /project-dir/entrypoint.r
[project-dir] routing...
+--------------+-------------------------------------------------+---------------+
| PLUMBER VERB | ENDPOINT | HANDLER |
+--------------+-------------------------------------------------+---------------+
| @get | http://localhost:8000/echo | function |
| @get | http://localhost:8000/dynamic/<param1>/<param2> | function |
| @get | http://localhost:8000/plot | function |
| @post | http://localhost:8000/sum | function |
| @get | http://localhost:8000/req | function |
| @assets | http://localhost:8000/files/static | static assets |
+--------------+-------------------------------------------------+---------------+
[project-dir] watching...
Starting server to listen on port 8000
A quick way to visualize your application's routing structure without starting the watcher
Usage: drip routes [flags]
-e
,--entry
(string) Plumber application entrypoint file (default "entrypoint.r")-h
,--help
help for routes
$ drip routes
Generate bash
completion commands for drip
Usage: drip completion [flags]
-h
,--help
help for completion
If you want to work on drip, you'll first need Go installed on your machine.
For local development, first make sure Go is properly installed and that a GOPATH has been set. You will also need to add $GOPATH/bin to your $PATH.
Next, using Git, clone this repository into $GOPATH/src/github.com/siegerts/drip.
$ git clone github.com/siegerts/drip
$ go build -o build/drip github.com/siegerts/drip
$ go install github.com/siegerts/drip