fix(boot_script): wait until the emqx running

This commit is contained in:
Shawn 2021-12-21 19:50:36 +08:00
parent 08da5f5267
commit c3eab16182
1 changed files with 22 additions and 1 deletions

View File

@ -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