Supports live reloading for Go
- Better features than github.com/pilu/fresh
- Supports cross compile and live reloading on host OS for
dockerusers ( Very Fast forDocker for Macuser ) - Supports cross compile by cgo ( C/C++ ) ( currently, works on macOS ( and target architecture is
amd64) only ) - Supports helper commands for
go rungo testgo build
rebirth needs configuration file ( rebirth.yml ) to running .
rebirth init create it .
rebirth.yml example is the following.
task:
migrate:
desc: migrate schema
commands:
- mysql ....
host:
docker: container_name
build:
main: path/to/main.go # change path to main package ( default: . )
init:
- echo 'init hook' # called once at starting
before:
- echo 'before hook' # called before build
after:
- echo 'after hook' # called after build
env:
CGO_LDFLAGS: /usr/local/lib/libz.a
run:
env:
RUNTIME_ENV: "fuga"
watch:
root: . # root directory for watching ( default: . )
ignore:
- vendortask: define custom commandhost: specify host information for running to an application ( currently, supportsdockeronly )build: specify ENV variables for buildingrun: specify ENV variables for runningwatch: specifyrootdirectory orignoredirectories for watching go file
$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth$ rebirth initrebirthExample tree
.
├── docker-compose.yml
├── main.go
└── rebirth.yml
main.go is your web application's source.
$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth$ brew install FiloSottile/musl-cross/musl-crossversion: '2'
services:
app:
image: golang:1.13.5
container_name: rebirth_app
volumes:
- '.:/go/src/app'
working_dir: /go/src/app
environment:
GO111MODULE: "on"
command: |
tail -f /dev/nullhost:
docker: rebirth_app # container_name in docker-compose.yml$ rebirth
# start live reloading !!
# build for docker container's architecture on macOS (e.g. GOOS=linux GOARCH=amd64
# execute built binary on target containerUsage:
rebirth [OPTIONS] <command>
Help Options:
-h, --help Show this help message
Available commands:
build execute 'go build' command
init create rebirth.yml for configuration
run execute 'go run' command
test execute 'go test' commandHelp cross compile your go script
$ rebirth build -o app script/hoge.goHelp cross compile for go test
$ rebirth test -v ./ -run HogeHelp cross compile for go run
$ rebirth run script/hoge.go~/work/app directory is mounted on the container as /go/src/app
- install
rebirthCLI (GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth) - run
rebirthand it cross compile myself for Linux ( GOOS=linux, GOARCH=amd64 ) and put it to.rebirthdirectory as__rebirth - copy
.rebirth/__rebirthto the container (.rebirthdirectory is mounted on the container ) - watch
main.go( by fsnotify )
- cross compile
main.gofor Linux and put to.rebirthdirectory asprogram - copy
.rebirth/programto the container
- run
__rebirthon the container __rebirthexecutesprogram- edit
main.go rebirthdetects file changed event
- cross compile
main.gofor Linux and put to.rebirthdirectory asprogram - copy
.rebirth/programto the container rebirthsend signal to__rebirthfor reloading (SIGHUP)__rebirthkill the current application and executeprogramas a new application
MIT