restart server whenever a new file is created in the .stack-work bin folderIf you're on Linux, you can install inotify-tools, run stack build --file-watch in one terminal and
declare -i p
trap 'kill "$p"' EXIT
while true; do
stack exec server arg1 arg2 & p=$!
inotifywait -q -e create .stack-work/install/*/*/*/bin/
in another (assuming your server executable is named server).
This'll restart server whenever a new file is created in the .stack-work bin folder. Of course it's even simpler if you're testing a one-shot command :)
(The sleep is there so it doesn't restart umpteen times while the file is in the process of being copied.)
last updated november 2016