aboutsummaryrefslogtreecommitdiff
path: root/cbt
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2017-06-15 23:15:37 -0400
committerGitHub <noreply@github.com>2017-06-15 23:15:37 -0400
commit494c302e738529ff2113d25910398d7b2b7a196c (patch)
treed67c88d10906647c7fd56229e6e56121a9107744 /cbt
parent618711302b7ea29de651c1f771eb3160e236b339 (diff)
parent09051773461b98d374d1b46dd0a2caa57768ab30 (diff)
downloadcbt-494c302e738529ff2113d25910398d7b2b7a196c.tar.gz
cbt-494c302e738529ff2113d25910398d7b2b7a196c.tar.bz2
cbt-494c302e738529ff2113d25910398d7b2b7a196c.zip
Merge pull request #523 from cvogt/restart
sbt-revolver like restart feature
Diffstat (limited to 'cbt')
-rwxr-xr-xcbt29
1 files changed, 26 insertions, 3 deletions
diff --git a/cbt b/cbt
index bc369de..e2014ec 100755
--- a/cbt
+++ b/cbt
@@ -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,20 +306,42 @@ 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" "$@"
break
else
+ for file in "${NAILGUN_SOURCES[@]}"; do
+ echo "$file" >> "$CBT_LOOP_FILE"
+ done
files=
if [ -f "$CBT_LOOP_FILE" ]; then
- files=($(cat "$CBT_LOOP_FILE"))
+ 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 ""
echo "Watching for file changes... (ctrl+c short press for loop, long press for abort)"
- #echo fswatch --one-event "${NAILGUN_SOURCES[@]}" "${files[@]}"
- fswatch --one-event "${NAILGUN_SOURCES[@]}" "${files[@]}"
+ for file in "${files[@]}"; do
+ if [ $file == "" ]; then
+ echo "warning: empty file found in loop file list" 1>&2
+ 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