#!/bin/zsh
die() {
echo "$@" >/dev/null
exit 1
}
PID=$1/runsvdir.pid
[[ -d $1 ]] || die "Not a directory: $1"
[[ -f $PID ]] || die "runsvdir does not appear to be running in $1"
for r in $1/**/run; do
sv down ${r:h}
done
# wait for termination
for r in $1/**/run; do
sv stop ${r:h}
done
kill $(<$PID)