Skip to content

Commit

Permalink
Configure Air for hot-reloads
Browse files Browse the repository at this point in the history
Use the 'make develop' target to start the service in hot-reload development mode.

Signed-off-by: Paul Balogh <[email protected]>
  • Loading branch information
javaducky committed May 4, 2024
1 parent e9d6e8f commit 45c3c78
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
46 changes: 46 additions & 0 deletions .air.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
root = "."
testdata_dir = "testdata"
tmp_dir = "tmp"

[build]
args_bin = []
bin = "./bin/weesvc"
cmd = "go build -o ./bin/weesvc .; ./bin/weesvc migrate"
delay = 1000
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
exclude_file = []
exclude_regex = ["_test.go"]
exclude_unchanged = false
follow_symlink = false
full_bin = ""
include_dir = []
include_ext = ["go", "tpl", "tmpl", "html"]
include_file = []
kill_delay = "0s"
log = "build-errors.log"
poll = false
poll_interval = 0
post_cmd = []
pre_cmd = []
rerun = false
rerun_delay = 500
send_interrupt = false
stop_on_error = false

[color]
app = ""
build = "yellow"
main = "magenta"
runner = "green"
watcher = "cyan"

[log]
main_only = false
time = false

[misc]
clean_on_exit = true

[screen]
clear_on_rebuild = false
keep_scroll = true
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ vet:
setup:
echo "Installing tools..."
go install golang.org/x/tools/cmd/goimports@latest

go install github.com/cosmtrek/air@latest

## build: Build the application.
build: deps imports fmt vet build-only
Expand Down Expand Up @@ -107,8 +107,12 @@ build-docker:
release-docker: build-docker
docker push $(DOCKER_IMAGE):$(DOCKER_TAG)

## develop: Start the application in hot-reload mode.
develop: build-only
air -c ./.air.toml -- serve


.PHONY: build build-all \
clean clean-all clean-artifacts \
deps fmt help imports \
deps develop fmt help imports \
setup test vet

0 comments on commit 45c3c78

Please sign in to comment.