Merge pull request #10297 from paulozulato/fix-eval

fix: keep eval command backward compatible with v4
This commit is contained in:
Paulo Zulato 2023-03-31 11:29:57 -03:00 committed by GitHub
commit 3765f5f120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 27 deletions

View File

@ -29,7 +29,7 @@ esac
is_node_up() {
local node="$1"
docker exec -i "$node" \
bash -c "emqx eval-erl \"['emqx@node1.emqx.io','emqx@node2.emqx.io'] = maps:get(running_nodes, ekka_cluster:info()).\"" > /dev/null 2>&1
bash -c "emqx eval \"['emqx@node1.emqx.io','emqx@node2.emqx.io'] = maps:get(running_nodes, ekka_cluster:info()).\"" > /dev/null 2>&1
}
is_node_listening() {

View File

@ -159,10 +159,7 @@ usage() {
echo "Print EMQX installation root dir"
;;
eval)
echo "Evaluate an Erlang or Elixir expression in the EMQX node"
;;
eval-erl)
echo "Evaluate an Erlang expression in the EMQX node, even on Elixir node"
echo "Evaluate an Erlang expression in the EMQX node."
;;
eval-ex)
echo "Evaluate an Elixir expression in the EMQX node. Only applies to Elixir node"
@ -231,7 +228,7 @@ usage() {
echo " Install Info: ertspath | root_dir"
echo " Runtime Status: pid | ping"
echo " Validate Config: check_config"
echo " Advanced: console_clean | escript | rpc | rpcterms | eval | eval-erl | eval-ex"
echo " Advanced: console_clean | escript | rpc | rpcterms | eval | eval-ex"
echo ''
echo "Execute '$REL_NAME COMMAND help' for more information"
;;
@ -1265,25 +1262,6 @@ case "${COMMAND}" in
eval)
assert_node_alive
shift
if [ "$IS_ELIXIR" = "yes" ]
then
"$REL_DIR/elixir" \
--hidden \
--name "rand-$(relx_gen_id)-$NAME" \
--cookie "$COOKIE" \
--boot "$REL_DIR/start_clean" \
--boot-var RELEASE_LIB "$ERTS_LIB_DIR" \
--vm-args "$REL_DIR/remote.vm.args" \
--erl "-start_epmd false -epmd_module ekka_epmd" \
--rpc-eval "$NAME" "$@"
else
relx_nodetool "eval" "$@"
fi
;;
eval-erl)
assert_node_alive
shift
relx_nodetool "eval" "$@"
;;

View File

@ -49,7 +49,7 @@ done
# Collect system info:
{
collect "$RUNNER_BIN_DIR"/emqx_ctl broker
collect "$RUNNER_BIN_DIR"/emqx eval-erl "'emqx_node_dump:sys_info()'"
collect "$RUNNER_BIN_DIR"/emqx eval "'emqx_node_dump:sys_info()'"
collect uname -a
collect uptime
@ -64,7 +64,7 @@ done
# Collect information about the configuration:
{
collect "$RUNNER_BIN_DIR"/emqx eval-erl "'emqx_node_dump:app_env_dump()'"
collect "$RUNNER_BIN_DIR"/emqx eval "'emqx_node_dump:app_env_dump()'"
} > "${CONF_DUMP}"
# Collect license info:

View File

@ -0,0 +1 @@
Keeps `eval` command backward compatible with v4 by evaluating only Erlang expressions, even on Elixir node. For Elixir expressions, use `eval-ex` command.