From 3a7d0c3e84962c3874883fef1937b95ac9755356 Mon Sep 17 00:00:00 2001 From: William Yang Date: Fri, 16 Jul 2021 13:59:04 +0200 Subject: [PATCH] fix(script): emqx die if call_hocon failed --- bin/emqx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/emqx b/bin/emqx index 0e019a4fc..048bbc34f 100755 --- a/bin/emqx +++ b/bin/emqx @@ -41,6 +41,12 @@ export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH" export ERTS_LIB_DIR="$ERTS_DIR/../lib" MNESIA_DATA_DIR="$RUNNER_DATA_DIR/mnesia/$NAME" +die() { + echo >&2 "$1" + errno=${2:-1} + exit "$errno" +} + relx_usage() { command="$1" @@ -200,8 +206,8 @@ relx_nodetool() { call_hocon() { export RUNNER_ROOT_DIR export REL_VSN - "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" hocon "$@" - return $? + "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" hocon "$@" \ + || die "ERROR: call_hocon failed: $*" $? } # Run an escript in the node's environment @@ -275,8 +281,7 @@ generate_config() { # shellcheck disable=SC2086 if ! relx_nodetool chkconfig $CONFIG_ARGS; then - echoerr "Error reading $CONFIG_ARGS" - exit 1 + die "Error reading $CONFIG_ARGS" fi } @@ -366,8 +371,7 @@ if [ -z "$COOKIE" ]; then fi if [ -z "$COOKIE" ]; then - echoerr "Please set node.cookie in $RUNNER_ETC_DIR/emqx.conf or override from environment variable EMQX_NODE_COOKIE" - exit 1 + die "Please set node.cookie in $RUNNER_ETC_DIR/emqx.conf or override from environment variable EMQX_NODE_COOKIE" fi # Support for IPv6 Dist. See: https://github.com/emqtt/emqttd/issues/1460