bin/tame: Inherit TAME_CMD_WAITTIME from environment
* bin/tame (TAME_CMD_WAITTIME): Renamed from `RUNNER_CMD_WAITTIME'. Inherit from environment, default 3. (command-runner): Sleep for an additional TAME_CMD_WAITTIME seconds after requesting runner reload to give more time in case of high load. (verify-runner-ack): Rename variable. (usage): Document env var. * build-aux/Makefile.am: Export TAME_CMD_WAITTIME.master
parent
8143207903
commit
8fa7d9ece6
21
bin/tame
21
bin/tame
|
@ -27,7 +27,7 @@ declare -ri EX_USAGE=64 # incorrect usage; sysexits.h
|
||||||
|
|
||||||
# maximum amount of time in seconds to wait for runner to ack
|
# maximum amount of time in seconds to wait for runner to ack
|
||||||
# before forcibly restarting it
|
# before forcibly restarting it
|
||||||
declare -ri RUNNER_CMD_WAITTIME=3
|
declare -ri TAME_CMD_WAITTIME="${TAME_CMD_WAITTIME:-3}"
|
||||||
|
|
||||||
# propagate to daemon
|
# propagate to daemon
|
||||||
export TAMED_STALL_SECONDS
|
export TAMED_STALL_SECONDS
|
||||||
|
@ -64,6 +64,9 @@ command-runner()
|
||||||
echo "warning: failed runner $id ack; requesting reload" >&2
|
echo "warning: failed runner $id ack; requesting reload" >&2
|
||||||
kill -HUP "$pid"
|
kill -HUP "$pid"
|
||||||
|
|
||||||
|
# give some extra time in case the host is under high load
|
||||||
|
sleep "$TAME_CMD_WAITTIME"
|
||||||
|
|
||||||
# try one last time
|
# try one last time
|
||||||
echo "$*" > "$base/0"
|
echo "$*" > "$base/0"
|
||||||
verify-runner-ack "$*" < "$base/1" || {
|
verify-runner-ack "$*" < "$base/1" || {
|
||||||
|
@ -109,14 +112,14 @@ verify-runner()
|
||||||
|
|
||||||
# Wait for command acknowledgment from runner
|
# Wait for command acknowledgment from runner
|
||||||
#
|
#
|
||||||
# The runner must respond within RUNNER_CMD_WAITTIME seconds
|
# The runner must respond within TAME_CMD_WAITTIME seconds
|
||||||
# and must echo back the command that was given. Otherwise,
|
# and must echo back the command that was given. Otherwise,
|
||||||
# this function returns with a non-zero status.
|
# this function returns with a non-zero status.
|
||||||
verify-runner-ack()
|
verify-runner-ack()
|
||||||
{
|
{
|
||||||
local -r cmd="${1?Missing command}"
|
local -r cmd="${1?Missing command}"
|
||||||
|
|
||||||
read -t"$RUNNER_CMD_WAITTIME" -r ack || return
|
read -t"$TAME_CMD_WAITTIME" -r ack || return
|
||||||
test "COMMAND $cmd" == "$ack" || {
|
test "COMMAND $cmd" == "$ack" || {
|
||||||
# TODO check for ack mismatch once output race condition is fixed
|
# TODO check for ack mismatch once output race condition is fixed
|
||||||
:
|
:
|
||||||
|
@ -233,14 +236,22 @@ Or: $0 --kill
|
||||||
Send command line CMDLINE to a tamed runner. Start tamed if
|
Send command line CMDLINE to a tamed runner. Start tamed if
|
||||||
not already running.
|
not already running.
|
||||||
|
|
||||||
|
If a runner does not acknlowedge a request in TAME_CMD_WAITTIME
|
||||||
|
seconds, it will be reloaded and given TAME_CMD_WAITTIME seconds
|
||||||
|
to come online. After that time has elapsed, the command will
|
||||||
|
be re-attempted, timing out again after TAME_CMD_WAITTIME and
|
||||||
|
and at that point giving up.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
--help show this message
|
--help show this message
|
||||||
--kill kill tamed
|
--kill kill tamed
|
||||||
-v, --verbose show runner logs
|
-v, --verbose show runner logs
|
||||||
|
|
||||||
Environment Variables:
|
Environment Variables:
|
||||||
TAME_VERBOSE when greater than zero, show runner logs
|
TAME_VERBOSE when greater than zero, show runner logs
|
||||||
(see also --verbose)
|
(see also --verbose)
|
||||||
|
TAME_CMD_WAITTIME number of seconds to wait for ack from
|
||||||
|
runner (default 3)
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
exit $EX_USAGE
|
exit $EX_USAGE
|
||||||
|
|
|
@ -79,6 +79,7 @@ default: program-ui c1map FORCE
|
||||||
SHELL = /bin/bash -O extglob
|
SHELL = /bin/bash -O extglob
|
||||||
|
|
||||||
# propagate to tame{,d}
|
# propagate to tame{,d}
|
||||||
|
export TAME_CMD_WAITTIME
|
||||||
export TAMED_STALL_SECONDS
|
export TAMED_STALL_SECONDS
|
||||||
|
|
||||||
all: program-data-copy
|
all: program-data-copy
|
||||||
|
|
Loading…
Reference in New Issue