Git Product home page Git Product logo

drip's Introduction

Overview

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

Requirements

drip utilizes Rscript to run the Plumber application process. For that reason, R is required for the CLI to correctly execute.

Download and Install

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.

Plumber Application Structure

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)

Use

Command: drip

Watch the current directory for changes using default option flag parameters.

Usage

  • drip [flags]
  • drip [command]

Available Commands:

  • help Help about any command
  • routes Display all routes in your Plumber application
  • version Print the version number of drip
  • watch Watch the current directory for any changes

Flags:

  • -h, --help help for drip

Example

# 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

Command: watch

Watch and rebuild the source if any changes are made across subdirectories

Usage

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])

Examples

# 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

Command: routes

A quick way to visualize your application's routing structure without starting the watcher

Usage

Usage: drip routes [flags]

  • -e, --entry (string) Plumber application entrypoint file (default "entrypoint.r")
  • -h, --help help for routes

Examples

$ drip routes

Command: completion

Generate bash completion commands for drip

Usage

Usage: drip completion [flags]

  • -h, --help help for completion

Developing and Contribution

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.