Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-10-16 22:16:25 -0400
committerMike Gerwitz <mike.gerwitz@rtspecialty.com>2018-10-16 22:23:57 -0400
commita4c8c0d8403c09b9bc2badd268c25b837704aef1 (patch)
tree7aa9b6efa99226ec3202928909b28832e491a5d9 /bin
parentb7167467b004a537d45b667c6f4c38f75fc9480a (diff)
downloadtame-a4c8c0d8403c09b9bc2badd268c25b837704aef1.tar.gz
tame-a4c8c0d8403c09b9bc2badd268c25b837704aef1.tar.bz2
tame-a4c8c0d8403c09b9bc2badd268c25b837704aef1.zip
bin/tame: Better runner re-try
Try to re-post message, since the previous message will have already been read (otherwise the previous echo would have hung). * bin/tame (EX_STALLED): New exit code. (command-runner): Re-post message after stall. If unrecoverable, provide a more clear error and exit with EX_STALLED.
Diffstat (limited to 'bin')
-rwxr-xr-xbin/tame10
1 files changed, 7 insertions, 3 deletions
diff --git a/bin/tame b/bin/tame
index 92f2ecd..17775f4 100755
--- a/bin/tame
+++ b/bin/tame
@@ -22,6 +22,7 @@ set -euo pipefail
declare -r mypath=$( dirname "$( readlink -f "$0" )" )
declare -ri EX_NOTAMED=1 # tried to start tamed but failed
+declare -ri EX_STALLED=2 # runner stalled and could not recover
declare -ri EX_USAGE=64 # incorrect usage; sysexits.h
# maximum amount of time in seconds to wait for runner to ack
@@ -62,10 +63,13 @@ command-runner()
verify-runner-ack "$*" < "$base/1" || {
echo "warning: failed runner $id ack; requesting reload" >&2
kill -HUP "$pid"
- sleep "$RUNNER_CMD_WAITTIME"
- # try once more
- verify-runner-ack "$*" < "$base/1" || exit
+ # try one last time
+ echo "$*" > "$base/0"
+ verify-runner-ack "$*" < "$base/1" || {
+ echo "error: runner $id still unresponsive; giving up" >&2
+ exit "$EX_STALLED"
+ }
}
# output lines from runner until we reach a line stating "DONE"