Supports live reloading for Go
Supports live reloading for Go
docker
users ( Very Fast for Docker for Mac
user )amd64
) only )go run
go test
go 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:
- vendor
task
: define custom commandhost
: specify host information for running to an application ( currently, supports docker
only )build
: specify ENV variables for buildingrun
: specify ENV variables for runningwatch
: specify root
directory or ignore
directories for watching go filerebirth
CLI$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
rebirth.yml
$ rebirth init
rebirth
rebirth
Example tree
.
├── docker-compose.yml
├── main.go
└── rebirth.yml
main.go
is your web application's source.
rebirth
CLI$ GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
$ brew install FiloSottile/musl-cross/musl-cross
version: '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/null
host:
docker: rebirth_app # container_name in docker-compose.yml
rebirth
$ rebirth
# start live reloading !!
# build for docker container's architecture on macOS (e.g. GOOS=linux GOARCH=amd64
# execute built binary on target container
Usage:
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' command
rebirth build
Help cross compile your go script
$ rebirth build -o app script/hoge.go
rebirth test
Help cross compile for go test
$ rebirth test -v ./ -run Hoge
rebirth run
Help cross compile for go run
$ rebirth run script/hoge.go
~/work/app
directory is mounted on the container as /go/src/app
rebirth
CLI ( GO111MODULE=on go get -u github.com/goccy/rebirth/cmd/rebirth
)rebirth
and it cross compile myself for Linux ( GOOS=linux, GOARCH=amd64 ) and put it to .rebirth
directory as __rebirth
.rebirth/__rebirth
to the container ( .rebirth
directory is mounted on the container )main.go
( by fsnotify )main.go
for Linux and put to .rebirth
directory as program
.rebirth/program
to the container__rebirth
on the container__rebirth
executes program
main.go
rebirth
detects file changed eventmain.go
for Linux and put to .rebirth
directory as program
.rebirth/program
to the containerrebirth
send signal to __rebirth
for reloading ( SIGHUP
)__rebirth
kill the current application and execute program
as a new applicationMIT