From 08da5f526713e3cd596d608094cdefb0bbd01042 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Tue, 21 Dec 2021 16:53:06 +0800 Subject: [PATCH 1/2] fix(boot_script): LD_LIBRARY_PATH: unbound variable --- bin/emqx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bin/emqx b/bin/emqx index 7862a98b8..b5f7a1903 100755 --- a/bin/emqx +++ b/bin/emqx @@ -204,7 +204,10 @@ fi if ! check_erlang_start >/dev/null 2>&1; then BUILT_ON="$(head -1 "${REL_DIR}/BUILT_ON")" ## failed to start, might be due to missing libs, try to be portable - export LD_LIBRARY_PATH="$DYNLIBS_DIR:$LD_LIBRARY_PATH" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH:-$DYNLIBS_DIR}" + if [ "$LD_LIBRARY_PATH" != "$DYNLIBS_DIR" ]; then + export LD_LIBRARY_PATH="$DYNLIBS_DIR:$LD_LIBRARY_PATH" + fi if ! check_erlang_start; then ## it's hopeless echoerr "FATAL: Unable to start Erlang." From c3eab1618288fd64caa2990cdb487da31cefa3ae Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Tue, 21 Dec 2021 19:50:36 +0800 Subject: [PATCH 2/2] fix(boot_script): wait until the emqx running --- bin/emqx | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/bin/emqx b/bin/emqx index b5f7a1903..00133ed0b 100755 --- a/bin/emqx +++ b/bin/emqx @@ -431,6 +431,26 @@ wait_for() { done } +wait_until_return_val() { + local RESULT + local WAIT_TIME + local CMD + RESULT="$1" + WAIT_TIME="$2" + shift 2 + CMD="$*" + while true; do + if [ "$($CMD 2>/dev/null)" = "$RESULT" ]; then + return 0 + fi + if [ "$WAIT_TIME" -le 0 ]; then + return 1 + fi + WAIT_TIME=$((WAIT_TIME - 1)) + sleep 1 + done +} + latest_vm_args() { local hint_var_name="$1" local vm_args_file @@ -556,7 +576,8 @@ case "${COMMAND}" in "$(relx_start_command)" WAIT_TIME=${WAIT_FOR_ERLANG:-15} - if wait_for "$WAIT_TIME" 'relx_nodetool' 'ping'; then + if wait_until_return_val "true" "$WAIT_TIME" 'relx_nodetool' \ + 'eval' 'emqx:is_running()'; then echo "$EMQX_DESCRIPTION $REL_VSN is started successfully!" exit 0 else