mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-10-28 15:11:11 +01:00
ADMIN: reload: introduce verbose and silent mode
By default haproxy-reload displays the error that are not emitted by haproxy, but only emitted by haproxy-reload. -s silent mode, don't display any error -v verbose mode, display the loading messages returned by the master CLI reload command upon error.
This commit is contained in:
parent
3ce597bfa2
commit
5d05f343b9
@ -2,10 +2,18 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
export VERBOSE=1
|
||||||
export TIMEOUT=90
|
export TIMEOUT=90
|
||||||
export MASTER_SOCKET=${MASTER_SOCKET:-/var/run/haproxy-master.sock}
|
export MASTER_SOCKET=${MASTER_SOCKET:-/var/run/haproxy-master.sock}
|
||||||
export RET=
|
export RET=
|
||||||
|
|
||||||
|
alert() {
|
||||||
|
if [ "$VERBOSE" -ge "1" ]; then
|
||||||
|
echo "[ALERT] $*" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
reload() {
|
reload() {
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
|
|
||||||
@ -14,13 +22,19 @@ reload() {
|
|||||||
elif [ "$line" = "Success=1" ]; then
|
elif [ "$line" = "Success=1" ]; then
|
||||||
RET=0
|
RET=0
|
||||||
elif [ "$line" = "Another reload is still in progress." ]; then
|
elif [ "$line" = "Another reload is still in progress." ]; then
|
||||||
echo "[ALERT] Another reload is still in progress." >&2
|
alert "$line"
|
||||||
|
elif [ "$line" = "--" ]; then
|
||||||
|
continue;
|
||||||
|
else
|
||||||
|
if [ "$RET" = 1 ] && [ "$VERBOSE" = "2" ]; then
|
||||||
|
echo "$line" >&2
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < <(echo "reload" | socat -t"${TIMEOUT}" "${MASTER_SOCKET}" -)
|
done < <(echo "reload" | socat -t"${TIMEOUT}" "${MASTER_SOCKET}" -)
|
||||||
|
|
||||||
if [ -z "$RET" ]; then
|
if [ -z "$RET" ]; then
|
||||||
echo "[ALERT] Couldn't finish the reload before the timeout (${TIMEOUT})." >&2
|
alert "Couldn't finish the reload before the timeout (${TIMEOUT})."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -39,7 +53,8 @@ usage() {
|
|||||||
echo " -S, --master-socket <path> Use the master socket at <path> (default: ${MASTER_SOCKET})"
|
echo " -S, --master-socket <path> Use the master socket at <path> (default: ${MASTER_SOCKET})"
|
||||||
echo " -d, --debug Debug mode, set -x"
|
echo " -d, --debug Debug mode, set -x"
|
||||||
echo " -t, --timeout Timeout (socat -t) (default: ${TIMEOUT})"
|
echo " -t, --timeout Timeout (socat -t) (default: ${TIMEOUT})"
|
||||||
echo " -v, --verbose Verbose mode"
|
echo " -s, --silent Slient mode (no output)"
|
||||||
|
echo " -v, --verbose Verbose mode (output from haproxy)"
|
||||||
echo " -h, --help This help"
|
echo " -h, --help This help"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Examples:"
|
echo "Examples:"
|
||||||
@ -58,6 +73,14 @@ main() {
|
|||||||
TIMEOUT="$2"
|
TIMEOUT="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-s|--silent)
|
||||||
|
VERBOSE=0
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-v|--verbose)
|
||||||
|
VERBOSE=2
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-d|--debug)
|
-d|--debug)
|
||||||
DEBUG=1
|
DEBUG=1
|
||||||
shift
|
shift
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user