fix(bin/emqx): do not try to find vm.args file for cold_eval

This commit is contained in:
Zaiming Shi 2021-09-08 13:43:52 +02:00
parent 0b11ab2d59
commit cca3a4414f
3 changed files with 29 additions and 17 deletions

View File

@ -297,7 +297,7 @@ sc_meta(Type, Meta) ->
hoconsc:mk(Type, Meta).
map(Name, Type) ->
hoconsc: map(Name, Type).
hoconsc:map(Name, Type).
ref(StructName) ->
ref(?MODULE, StructName).

View File

@ -355,6 +355,16 @@ case "$1" in
;;
esac
IS_NO_CONNECTION_COMMAND='no'
case "$1" in
cold_eval)
IS_NO_CONNECTION_COMMAND='yes'
;;
*)
;;
esac
## Possible ways to configure emqx node name:
## 1. configure node.name in emqx.conf
## 2. override with environment variable EMQX_NODE_NAME
@ -362,18 +372,17 @@ esac
## or long name (with '@') e.g. 'emqx@example.net' or 'emqx@127.0.0.1'
NAME="${EMQX_NODE_NAME:-}"
if [ -z "$NAME" ]; then
if [ "$IS_BOOT_COMMAND" = 'no' ]; then
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
# for boot commands, inspect emqx.conf for node name
NAME="$(call_hocon -s $SCHEMA_MOD -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")"
elif [ "$IS_NO_CONNECTION_COMMAND" = 'yes' ]; then
# this command requires no connection to the target beam node, do nothing
:
else
# for non-boot commands, inspect vm.<time>.args for node name
# shellcheck disable=SC2012,SC2086
LATEST_VM_ARGS="$(ls -t $CONFIGS_DIR/vm.*.args | head -1)"
if [ -z "$LATEST_VM_ARGS" ]; then
echoerr "no_vm_arg_file_found_for $1 in $CONFIGS_DIR/"
exit 1
fi
NAME="$(grep -E '^-s?name' "$LATEST_VM_ARGS" | awk '{print $2}')"
else
# for boot commands, inspect emqx.conf for node name
NAME="$(call_hocon -s $SCHEMA_MOD -c "$RUNNER_ETC_DIR"/emqx.conf get node.name | tr -d \")"
fi
fi
@ -396,13 +405,12 @@ COOKIE="${EMQX_NODE_COOKIE:-}"
if [ -z "$COOKIE" ]; then
if [ "$IS_BOOT_COMMAND" = 'yes' ]; then
COOKIE="$(call_hocon -s $SCHEMA_MOD -c "$RUNNER_ETC_DIR"/emqx.conf get node.cookie | tr -d \")"
elif [ "$IS_NO_CONNECTION_COMMAND" = 'yes' ]; then
# this command requires no connection to the target beam node, do nothing
COOKIE="whatever"
else
# shellcheck disable=SC2012,SC2086
LATEST_VM_ARGS="$(ls -t $CONFIGS_DIR/vm.*.args | head -1)"
if [ -z "$LATEST_VM_ARGS" ]; then
echoerr "no_vm_arg_file_found_for $1 in $CONFIGS_DIR/"
exit 1
fi
COOKIE="$(grep -E '^-setcookie' "$LATEST_VM_ARGS" | awk '{print $2}')"
fi
fi

12
build
View File

@ -62,6 +62,13 @@ log() {
echo "===< $msg"
}
docgen() {
local conf_doc
conf_doc="$(pwd)/_build/${PROFILE}/rel/emqx/etc/emqx-config-doc.html"
echo "===< Generating config document $conf_doc"
./_build/"$PROFILE"/rel/emqx/bin/emqx cold_eval "file:write_file('$conf_doc', hocon_schema_html:gen(emqx_machine_schema, \"EMQ X ${PKG_VSN}\"))"
}
make_rel() {
# shellcheck disable=SC1010
./rebar3 as "$PROFILE" do release,tar
@ -69,10 +76,7 @@ make_rel() {
echo "gpb should not be included in the release"
exit 1
fi
local conf_doc
conf_doc="$(pwd)/_build/${PROFILE}/rel/emqx/etc/emqx-config-doc.html"
echo "===< Generating config document $conf_doc"
./_build/"$PROFILE"/rel/emqx/bin/emqx cold_eval "file:write_file('$conf_doc', hocon_schema_html:gen(emqx_machine_schema, \"EMQ X ${PKG_VSN}\"))"
docgen
}
## unzip previous version .zip files to _build/$PROFILE/rel/emqx/releases before making relup