=== modified file 'sv.ssh-master.check' --- sv.ssh-master.check 2013-05-21 06:10:26 +0000 +++ sv.ssh-master.check 2013-05-04 12:54:56 +0000 @@ -1,3 +1,3 @@ #!/bin/zsh source ./args -ssh -O check "${args[@]}" &>/dev/null +ssh -O check "${args[@]}" === modified file 'usv.bg' --- usv.bg 2013-05-21 06:10:26 +0000 +++ usv.bg 2013-05-15 21:13:18 +0000 @@ -1,28 +1,9 @@ #!/bin/zsh D=${1:-~/service} [[ -d $D ]] || { echo 'invalid service directory:' $D; exit 1 } - -DSEC_WAIT=10 - +touch $D/lock if [[ -o xtrace ]]; then - usv.check() { zsh -x ${commands[usv.check]} "$@" } + exec flock -w 5 $D/lock zsh -x ${commands[usv.bg_locked]} "$@" +else + exec flock -w 5 $D/lock usv.bg_locked "$@" fi - -touch $D/lock -( - flock -w 5 3 - if ! usv.check $D; then - ( - flock -u $D/lock - setsid usv.run $D 2>&1 | logger -t svdir.${${D:t}##.} - ) 3&2 "failed to spawn runsvdir in: $D" - exit 1 - fi - done - fi -) 3<$D/lock === added file 'usv.bg_locked' --- usv.bg_locked 1970-01-01 00:00:00 +0000 +++ usv.bg_locked 2013-05-09 11:23:12 +0000 @@ -0,0 +1,19 @@ +#!/bin/zsh +D=${1:-~/service} +[[ -d $D ]] || { echo 'invalid service directory:' $D; exit 1 } +DSEC_WAIT=10 +if [[ -o xtrace ]]; then + usv.check() { zsh -x ${commands[usv.check]} "$@" } +fi +if ! usv.check $D; then + setsid usv.run $D 2>&1 | logger -t svdir.${${D:t}##.} &! + while ! usv.check $D; do + DSEC_WAIT=$(( DSEC_WAIT - 1 )) + sleep '0.1s' + if ! (($DSEC_WAIT)); then + print >&2 "failed to spawn runsvdir in: $D" + exit 1 + fi + done +fi +