• Stars
    star
    81
  • Rank 400,299 (Top 8 %)
  • Language
    Go
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Builds and restarts a Go project when it crashes or some watched file changes

gaper

Used to build and restart a Go project when it crashes or some watched file changes
Aimed to be used in development only.


Software License Linux - Build Status Windows - Build status Coverage Status Go Doc Go Report Card Powered By: GoReleaser

Changelog

See Releases for detailed history changes.

Installation

Using go tooling:

go get -u github.com/maxcnunes/gaper/cmd/gaper

Or, downloading the binary instead (example for version 1.1.0, make sure you are using the latest version though):

curl -SL https://github.com/maxcnunes/gaper/releases/download/v1.1.0/gaper_1.1.0_linux_amd64.tar.gz | tar -xvzf - -C "${GOPATH}/bin"

Usage

NAME:
   gaper - Used to build and restart a Go project when it crashes or some watched file changes

USAGE:
   gaper [global options] command [command options] [arguments...]

VERSION:
   version

COMMANDS:
     help, h  Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --bin-name value                 name for the binary built by gaper for the executed program (default current directory name)
   --build-path value               path to the program source code (default: ".")
   --build-args value               arguments used on building the program
   --program-args value             arguments used on executing the program
   --verbose                        turns on the verbose messages from gaper
   --disable-default-ignore         turns off default ignore for hidden files and folders, "*_test.go" files, and vendor folder
   --watch value, -w value          list of folders or files to watch for changes
   --ignore value, -i value         list of folders or files to ignore for changes
   --poll-interval value, -p value  how often in milliseconds to poll watched files for changes (default: 500)
   --extensions value, -e value     extensions to watch for changes (default: "go")
   --no-restart-on value, -n value  don't automatically restart the supervised program if it ends:
                                      if "error", an exit code of 0 will still restart.
                                      if "exit", no restart regardless of exit code.
                                      if "success", no restart only if exit code is 0.
   --help, -h                       show help
   --version, -v                    print the version

Watch and Ignore paths

For those options Gaper supports static paths (e.g. build/, seed.go) or glob paths (e.g. migrations/**/up.go, *_test.go).

On using a path to a directory please add a / at the end (e.g. build/) to make sure Gaper won't include other matches that starts with that same value (e.g. build/, build_settings.go).

Default ignore settings

Since in most projects there is no need to watch changes for:

  • hidden files and folders
  • test files (*_test.go)
  • vendor folder

Gaper by default ignores those cases already. Although, if you need Gaper to watch those files anyway it is possible to disable this setting with --disable-default-ignore argument.

Watch method

Currently Gaper uses polling to watch file changes. We have plans to support fs events though in a near future.

Examples

Using all defaults provided by Gaper:

gaper

Example providing a few custom configurations:

gaper \
    --bin-name build/api-dev \
    --build-path cmd/server \
    --build-args "-ldflags=\"-X 'main.Version=dev'" \
    -w 'public/**' -w '*.go' \
    -e js -e css -e html \
    --ignore './**/*_mock.go' \
    --program-args "-arg1 ok -arg2=nope" \
    --watch .

Contributing

See the Contributing guide for steps on how to contribute to this project.

Reference

This package was heavily inspired by gin and node-supervisor.

Basically, Gaper is a mixing of those projects above. It started from gin code base and I rewrote it aiming to get something similar to node-supervisor (but simpler). A big thanks for those projects and for the people behind it! :clap::clap:

How is Gaper different of Gin

The main difference is that Gaper removes a layer of complexity from Gin which has a proxy running on top of the executed server. It allows to postpone a build and reload the server when the first call hits it. With Gaper we don't care about that feature, it just restarts your server whenever a change is made.

More Repositories

1

waitforit

Wait until an address become available.
Go
172
star
2

httpfake

Httpfake – A Golang httptest wrapper for easily setting up a fake server
Go
116
star
3

elixir-phoenix-rest-api

A simple example of a rest API with elixir and phoenix
Elixir
75
star
4

go-uptime-api

Uptime monitor API written in Golang
Go
33
star
5

mongo-to-knex

Applies a query like mongo standards to knex query builder
JavaScript
17
star
6

docker-unrar

11
star
7

solr-query-builder

A query builder for Solr in node js
JavaScript
8
star
8

remove-reactid-attributes

Clean up HTML from a generated page with React
HTML
6
star
9

go-uptime-app

Uptime monitor APP using React js
JavaScript
6
star
10

i-sweated-yesterday

A small application to count the days I did any exercise (sport)
Python
6
star
11

docker-url-redirect

Lightweight docker image (2 MB) to redirect URLs.
Go
5
star
12

SignalR-Auction

Example using SignalR to build a simple Auction App
JavaScript
5
star
13

dotfiles

Lua
5
star
14

git-web-hook

JavaScript
4
star
15

docker-electron-distribution

A image based in debian:jessie with necessary dependencies to build/pack and create installers for an electron application from Linux to any other OS
Shell
4
star
16

flaskgaedemo

Flask and Google App Engine
Python
3
star
17

ranking

JavaScript
3
star
18

ngs

n git satus - a tool to check the status of multiple git repositories
Go
3
star
19

factory-mysql-fixtures

Factory to load fixtures on mysql database.
JavaScript
3
star
20

slack-files

Easy control over the Slack files clean up
Go
3
star
21

rancheros-guest

Ruby
2
star
22

tokenizer

Generates oauth2 tokens
Go
2
star
23

GoogleMapsAPI3

Funcionalidades básicas do Google Maps API 3: Mapa, rotas, marcadores, bounds...
JavaScript
2
star
24

SOSPosto

Estudo de caso prático em WCF+SOA+MySql da minha monografia "Modelagem UML para SOA"
C#
1
star
25

learning-assembly-arm64-apple

Assembly
1
star
26

maxcnunes.github.io

My Blog
HTML
1
star
27

poll-service-go-gorilla

Go
1
star
28

go-queue

A modest implementation of queue in go
Go
1
star
29

flask_bravi

Short demo of an apresentention about Flask
Python
1
star
30

chakra-app-colorMode-undefined

TypeScript
1
star
31

playwright-electron-xvfb

1
star
32

winston-slackihook

JavaScript
1
star
33

Perfin

Personal Finance Control - Easy and Simple
JavaScript
1
star