alexedwards/go-reload — pull request #4 by pope (2014-03-16 07:20:08+00:00)
Title: Make the bash script a bit less clumsy on close.

When the app closes, the script kills off all inotifywait commands. Well, if you
have have inotifywait commands running on your machine, those get killed! Not
cool. Now, we can just kill all of the processes owned by the script and no one
else.

But app close isn't the only thing addressed. The other thing tackled in here is
an issue where if inotify notices changes faster than the go can recompile, then
you can get into a case where an older version of the app can be running while a
new version may not run because of a conflicting port. The problem was that the
kill command was focusing on the compiled app; but the compilation takes a
little time. So if Go hasn't finished compiling the app, then there's nothing to
kill and Go just compiles the app and runs it. Instead of targetting the running
go program, the script now attempts to kill "go run" and the Go app, if that app
has already started"

Lastly, I added some documentation to the functions in the file. I used the
Google shell style guide[1] in lieu of not knowing what else to use. The nice
part is that the global variables required for each function are documented.

[1] - https://google-styleguide.googlecode.com/svn/trunk/shell.xml