Created
November 6, 2019 10:01
-
-
Save oLaVanBac/6ef942db63526a5eb9a7a5858a37cfaa to your computer and use it in GitHub Desktop.
simple golang live reload
This file contains hidden or 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
| #!/bin/sh | |
| PID=0 | |
| stop() { | |
| if ps -p $PID | |
| then | |
| echo "Stopping... $PID" | |
| kill $PID | |
| fi | |
| echo "Stopped" | |
| } | |
| start() { | |
| echo "Starting..." | |
| go build | |
| ./$(basename $PWD) & | |
| PID=$! | |
| echo "Started" | |
| } | |
| ctrl_c() { | |
| stop | |
| exit 0 | |
| } | |
| trap ctrl_c INT | |
| start | |
| while inotifywait -qr -e modify . | |
| do | |
| stop | |
| start | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment