Skip to content

Instantly share code, notes, and snippets.

@doitian
Last active October 8, 2017 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doitian/b171d8b1bdd461ec7e362f3b10916a73 to your computer and use it in GitHub Desktop.
Save doitian/b171d8b1bdd461ec7e362f3b10916a73 to your computer and use it in GitHub Desktop.
Go process livereload for development
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
@doitian
Copy link
Author

doitian commented Oct 8, 2017

See https://github.com/mattgreen/watchexec as a simpler solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment