diff options
author | Christopher Vogt <oss.nsp@cvogt.org> | 2017-06-15 22:38:53 -0400 |
---|---|---|
committer | Christopher Vogt <oss.nsp@cvogt.org> | 2017-06-15 22:43:59 -0400 |
commit | 09051773461b98d374d1b46dd0a2caa57768ab30 (patch) | |
tree | d67c88d10906647c7fd56229e6e56121a9107744 /cbt | |
parent | b5194aab6f1f57aff6e4538acaf91245fdf15039 (diff) | |
download | cbt-09051773461b98d374d1b46dd0a2caa57768ab30.tar.gz cbt-09051773461b98d374d1b46dd0a2caa57768ab30.tar.bz2 cbt-09051773461b98d374d1b46dd0a2caa57768ab30.zip |
add sbt-resolver like restart feature
Diffstat (limited to 'cbt')
-rwxr-xr-x | cbt | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -290,6 +290,7 @@ stage1 () { USER_PRESSED_CTRL_C=130 CBT_LOOP_FILE="$CWD/target/.cbt-loop.tmp" +CBT_KILL_FILE="$CWD/target/.cbt-kill.tmp" if [ $loop -eq 0 ]; then which fswatch >/dev/null 2>/dev/null export fswatch_installed=$? @@ -305,6 +306,9 @@ while true; do if [ -f "$CBT_LOOP_FILE" ]; then rm "$CBT_LOOP_FILE" fi + if [ -f "$CBT_KILL_FILE" ]; then + rm "$CBT_KILL_FILE" + fi stage1 "$@" if [ ! $loop -eq 0 ] || [ $exitCode -eq $USER_PRESSED_CTRL_C ]; then log "not looping, exiting" "$@" @@ -316,6 +320,10 @@ while true; do files= if [ -f "$CBT_LOOP_FILE" ]; then files=($(sort "$CBT_LOOP_FILE")) + fi + pids= + if [ -f "$CBT_KILL_FILE" ]; then + pids=($(cat "$CBT_KILL_FILE")) # FIXME: should we uniq here? #rm "$CBT_LOOP_FILE" fi echo "" @@ -326,6 +334,14 @@ while true; do fi done fswatch --one-event "${files[@]}" + for pid in "${pids[@]}"; do + if [ $pid == "" ]; then + echo "warning: empty pid found in pid kill list" 1>&2 + else + log "killing process $pid" + kill -KILL $pid + fi + done fi done |