|
|
@@ -13,6 +13,35 @@ if [ "$DEBUG" -eq 2 ]; then
|
|
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
|
|
fi
|
|
|
|
|
|
+logerr() {
|
|
|
+ if [ "${TERM:-dumb}" = dumb ]; then
|
|
|
+ echo -e "ERROR: $*" 1>&2
|
|
|
+ else
|
|
|
+ echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+logwarn() {
|
|
|
+ if [ "${TERM:-dumb}" = dumb ]; then
|
|
|
+ echo "WARNING: $*"
|
|
|
+ else
|
|
|
+ echo "$(tput setaf 3)WARNING: $*$(tput sgr0)"
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+logdebug() {
|
|
|
+ if [ "$DEBUG" -eq 1 ]; then
|
|
|
+ echo "DEBUG: $*"
|
|
|
+ fi
|
|
|
+}
|
|
|
+
|
|
|
+die() {
|
|
|
+ set +x
|
|
|
+ logerr "$1"
|
|
|
+ errno=${2:-1}
|
|
|
+ exit "$errno"
|
|
|
+}
|
|
|
+
|
|
|
# We need to find real directory with emqx files on all platforms
|
|
|
# even when bin/emqx is symlinked on several levels
|
|
|
# - readlink -f works perfectly, but `-f` flag has completely different meaning in BSD version,
|
|
|
@@ -34,6 +63,17 @@ else
|
|
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(realpath "$0" || echo "$0")")"/..; pwd -P)"
|
|
|
fi
|
|
|
|
|
|
+BASE_RUNNER_ROOT_DIR="${BASE_RUNNER_ROOT_DIR:-$RUNNER_ROOT_DIR}"
|
|
|
+
|
|
|
+if [ -f "$RUNNER_ROOT_DIR/relup/version" ]; then
|
|
|
+ TARGET_VSN=$(cat "$RUNNER_ROOT_DIR/relup/version")
|
|
|
+ export BASE_RUNNER_ROOT_DIR
|
|
|
+ logwarn "Loading emqx from hot upgrade dir: $RUNNER_ROOT_DIR/relup"
|
|
|
+ exec $RUNNER_ROOT_DIR/relup/$TARGET_VSN/bin/emqx "$@"
|
|
|
+else
|
|
|
+ logdebug "Loading emqx from $RUNNER_ROOT_DIR"
|
|
|
+fi
|
|
|
+
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
|
. "$RUNNER_ROOT_DIR"/releases/emqx_vars
|
|
|
|
|
|
@@ -60,35 +100,6 @@ export PROGNAME="erl"
|
|
|
export ERTS_LIB_DIR="$RUNNER_ROOT_DIR/lib"
|
|
|
DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
|
|
|
|
|
|
-logerr() {
|
|
|
- if [ "${TERM:-dumb}" = dumb ]; then
|
|
|
- echo -e "ERROR: $*" 1>&2
|
|
|
- else
|
|
|
- echo -e "$(tput setaf 1)ERROR: $*$(tput sgr0)" 1>&2
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-logwarn() {
|
|
|
- if [ "${TERM:-dumb}" = dumb ]; then
|
|
|
- echo "WARNING: $*"
|
|
|
- else
|
|
|
- echo "$(tput setaf 3)WARNING: $*$(tput sgr0)"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-logdebug() {
|
|
|
- if [ "$DEBUG" -eq 1 ]; then
|
|
|
- echo "DEBUG: $*"
|
|
|
- fi
|
|
|
-}
|
|
|
-
|
|
|
-die() {
|
|
|
- set +x
|
|
|
- logerr "$1"
|
|
|
- errno=${2:-1}
|
|
|
- exit "$errno"
|
|
|
-}
|
|
|
-
|
|
|
assert_node_alive() {
|
|
|
if ! relx_nodetool "ping" > /dev/null; then
|
|
|
exit 1
|
|
|
@@ -598,7 +609,7 @@ DATA_DIR="$(get_boot_config 'node.data_dir')"
|
|
|
DATA_DIR="${DATA_DIR%/}"
|
|
|
if [[ $DATA_DIR != /* ]]; then
|
|
|
# relative path
|
|
|
- DATA_DIR="${RUNNER_ROOT_DIR}/${DATA_DIR}"
|
|
|
+ DATA_DIR="${BASE_RUNNER_ROOT_DIR}/${DATA_DIR}"
|
|
|
fi
|
|
|
CONFIGS_DIR="$DATA_DIR/configs"
|
|
|
mkdir -p "$CONFIGS_DIR"
|
|
|
@@ -1060,7 +1071,7 @@ nodetool_shutdown() {
|
|
|
logger -t "${REL_NAME}[${PID}]" "STOP: OK"
|
|
|
}
|
|
|
|
|
|
-cd "$RUNNER_ROOT_DIR"
|
|
|
+cd "$BASE_RUNNER_ROOT_DIR"
|
|
|
|
|
|
case "${COMMAND}" in
|
|
|
start)
|