Last active
October 8, 2017 07:58
-
-
Save doitian/b171d8b1bdd461ec7e362f3b10916a73 to your computer and use it in GitHub Desktop.
Go process livereload for development
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PID = tmp/server.pid | |
APPNAME = app | |
FSWATCH_PATTERNS = ./ | |
server: | |
@make restart | |
@fswatch -o $(FSWATCH_PATTERNS) | xargs -n1 -I{} make restart || make kill | |
@make kill | |
kill: | |
@cat $(PID) 2>/dev/null | xargs -L1 kill || true | |
@rm -f $(PID) | |
restart: | |
@make kill | |
@go build -o $(APPNAME) | |
@echo ">>>>>>>>>>>>>>>>>>>>>>>>>> Restarted at $$(date)" | |
@mkdir -p tmp | |
@./$(APPNAME) -logtostderr -v=3 & echo $$! > $(PID) | |
.PHONY: server kill restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://github.com/mattgreen/watchexec as a simpler solution.