feat: support starting emqx from relup dir
We put all of the unpacked files into `relup` dir, and warn the user if boot from it
This commit is contained in:
parent
5fca0a16f9
commit
c6b02bc13f
109
bin/emqx
109
bin/emqx
|
@ -13,53 +13,6 @@ if [ "$DEBUG" -eq 2 ]; then
|
||||||
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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,
|
|
||||||
# so we can't use it universally.
|
|
||||||
# - `stat -f%R` on MacOS does exactly what `readlink -f` does on Linux, but we can't use it
|
|
||||||
# as a universal solution either because GNU stat has different syntax and this argument is invalid.
|
|
||||||
# Also, version of stat which supports this syntax is only available since MacOS 12
|
|
||||||
if [ "$(uname -s)" == 'Darwin' ]; then
|
|
||||||
product_version="$(sw_vers -productVersion | cut -d '.' -f 1)"
|
|
||||||
if [ "$product_version" -ge 12 ]; then
|
|
||||||
# if homebrew coreutils package is installed, GNU version of stat can take precedence,
|
|
||||||
# so we use absolute path to ensure we are calling MacOS default
|
|
||||||
RUNNER_ROOT_DIR="$(cd "$(dirname "$(/usr/bin/stat -f%R "$0" || echo "$0")")"/..; pwd -P)"
|
|
||||||
else
|
|
||||||
# try our best to resolve link on MacOS <= 11
|
|
||||||
RUNNER_ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
RUNNER_ROOT_DIR="$(cd "$(dirname "$(realpath "$0" || echo "$0")")"/..; pwd -P)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# shellcheck disable=SC1090,SC1091
|
|
||||||
. "$RUNNER_ROOT_DIR"/releases/emqx_vars
|
|
||||||
|
|
||||||
# defined in emqx_vars
|
|
||||||
export RUNNER_ROOT_DIR
|
|
||||||
export EMQX_ETC_DIR
|
|
||||||
export REL_VSN
|
|
||||||
export SCHEMA_MOD
|
|
||||||
export IS_ENTERPRISE
|
|
||||||
|
|
||||||
RUNNER_SCRIPT="$RUNNER_BIN_DIR/$REL_NAME"
|
|
||||||
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
|
|
||||||
REL_DIR="$RUNNER_ROOT_DIR/releases/$REL_VSN"
|
|
||||||
|
|
||||||
WHOAMI=$(whoami 2>/dev/null || id -u)
|
|
||||||
|
|
||||||
# hocon try to read environment variables starting with "EMQX_"
|
|
||||||
export HOCON_ENV_OVERRIDE_PREFIX='EMQX_'
|
|
||||||
|
|
||||||
export ERTS_DIR="$RUNNER_ROOT_DIR/erts-$ERTS_VSN"
|
|
||||||
export BINDIR="$ERTS_DIR/bin"
|
|
||||||
export EMU="beam"
|
|
||||||
export PROGNAME="erl"
|
|
||||||
export ERTS_LIB_DIR="$RUNNER_ROOT_DIR/lib"
|
|
||||||
DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
|
|
||||||
|
|
||||||
logerr() {
|
logerr() {
|
||||||
if [ "${TERM:-dumb}" = dumb ]; then
|
if [ "${TERM:-dumb}" = dumb ]; then
|
||||||
echo -e "ERROR: $*" 1>&2
|
echo -e "ERROR: $*" 1>&2
|
||||||
|
@ -89,6 +42,64 @@ die() {
|
||||||
exit "$errno"
|
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,
|
||||||
|
# so we can't use it universally.
|
||||||
|
# - `stat -f%R` on MacOS does exactly what `readlink -f` does on Linux, but we can't use it
|
||||||
|
# as a universal solution either because GNU stat has different syntax and this argument is invalid.
|
||||||
|
# Also, version of stat which supports this syntax is only available since MacOS 12
|
||||||
|
if [ "$(uname -s)" == 'Darwin' ]; then
|
||||||
|
product_version="$(sw_vers -productVersion | cut -d '.' -f 1)"
|
||||||
|
if [ "$product_version" -ge 12 ]; then
|
||||||
|
# if homebrew coreutils package is installed, GNU version of stat can take precedence,
|
||||||
|
# so we use absolute path to ensure we are calling MacOS default
|
||||||
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(/usr/bin/stat -f%R "$0" || echo "$0")")"/..; pwd -P)"
|
||||||
|
else
|
||||||
|
# try our best to resolve link on MacOS <= 11
|
||||||
|
RUNNER_ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
# defined in emqx_vars
|
||||||
|
export RUNNER_ROOT_DIR
|
||||||
|
export EMQX_ETC_DIR
|
||||||
|
export REL_VSN
|
||||||
|
export SCHEMA_MOD
|
||||||
|
export IS_ENTERPRISE
|
||||||
|
|
||||||
|
RUNNER_SCRIPT="$RUNNER_BIN_DIR/$REL_NAME"
|
||||||
|
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
|
||||||
|
REL_DIR="$RUNNER_ROOT_DIR/releases/$REL_VSN"
|
||||||
|
|
||||||
|
WHOAMI=$(whoami 2>/dev/null || id -u)
|
||||||
|
|
||||||
|
# hocon try to read environment variables starting with "EMQX_"
|
||||||
|
export HOCON_ENV_OVERRIDE_PREFIX='EMQX_'
|
||||||
|
|
||||||
|
export ERTS_DIR="$RUNNER_ROOT_DIR/erts-$ERTS_VSN"
|
||||||
|
export BINDIR="$ERTS_DIR/bin"
|
||||||
|
export EMU="beam"
|
||||||
|
export PROGNAME="erl"
|
||||||
|
export ERTS_LIB_DIR="$RUNNER_ROOT_DIR/lib"
|
||||||
|
DYNLIBS_DIR="$RUNNER_ROOT_DIR/dynlibs"
|
||||||
|
|
||||||
assert_node_alive() {
|
assert_node_alive() {
|
||||||
if ! relx_nodetool "ping" > /dev/null; then
|
if ! relx_nodetool "ping" > /dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -598,7 +609,7 @@ DATA_DIR="$(get_boot_config 'node.data_dir')"
|
||||||
DATA_DIR="${DATA_DIR%/}"
|
DATA_DIR="${DATA_DIR%/}"
|
||||||
if [[ $DATA_DIR != /* ]]; then
|
if [[ $DATA_DIR != /* ]]; then
|
||||||
# relative path
|
# relative path
|
||||||
DATA_DIR="${RUNNER_ROOT_DIR}/${DATA_DIR}"
|
DATA_DIR="${BASE_RUNNER_ROOT_DIR}/${DATA_DIR}"
|
||||||
fi
|
fi
|
||||||
CONFIGS_DIR="$DATA_DIR/configs"
|
CONFIGS_DIR="$DATA_DIR/configs"
|
||||||
mkdir -p "$CONFIGS_DIR"
|
mkdir -p "$CONFIGS_DIR"
|
||||||
|
@ -1060,7 +1071,7 @@ nodetool_shutdown() {
|
||||||
logger -t "${REL_NAME}[${PID}]" "STOP: OK"
|
logger -t "${REL_NAME}[${PID}]" "STOP: OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
cd "$RUNNER_ROOT_DIR"
|
cd "$BASE_RUNNER_ROOT_DIR"
|
||||||
|
|
||||||
case "${COMMAND}" in
|
case "${COMMAND}" in
|
||||||
start)
|
start)
|
||||||
|
|
|
@ -392,9 +392,9 @@ overlay_vars_pkg(bin) ->
|
||||||
{platform_etc_dir, "etc"},
|
{platform_etc_dir, "etc"},
|
||||||
{platform_plugins_dir, "plugins"},
|
{platform_plugins_dir, "plugins"},
|
||||||
{runner_bin_dir, "$RUNNER_ROOT_DIR/bin"},
|
{runner_bin_dir, "$RUNNER_ROOT_DIR/bin"},
|
||||||
{emqx_etc_dir, "$RUNNER_ROOT_DIR/etc"},
|
{emqx_etc_dir, "$BASE_RUNNER_ROOT_DIR/etc"},
|
||||||
{runner_lib_dir, "$RUNNER_ROOT_DIR/lib"},
|
{runner_lib_dir, "$RUNNER_ROOT_DIR/lib"},
|
||||||
{runner_log_dir, "$RUNNER_ROOT_DIR/log"},
|
{runner_log_dir, "$BASE_RUNNER_ROOT_DIR/log"},
|
||||||
{runner_user, ""},
|
{runner_user, ""},
|
||||||
{is_elixir, "no"}
|
{is_elixir, "no"}
|
||||||
];
|
];
|
||||||
|
|
|
@ -14,8 +14,7 @@
|
||||||
target_version => "5.6.1+patch.A",
|
target_version => "5.6.1+patch.A",
|
||||||
from_version => "5.6.1",
|
from_version => "5.6.1",
|
||||||
code_changes =>
|
code_changes =>
|
||||||
[ {load_module, emqx_post_upgrade}
|
[ {load_module, emqx_broker}
|
||||||
, {load_module, emqx_broker}
|
|
||||||
, {load_module, emqx_metrics}
|
, {load_module, emqx_metrics}
|
||||||
, {load_module, emqx_persistent_message}
|
, {load_module, emqx_persistent_message}
|
||||||
, {load_module, emqx_dashboard_monitor}
|
, {load_module, emqx_dashboard_monitor}
|
||||||
|
|
Loading…
Reference in New Issue