chore(mix): fix: use Elixir's own rpc-eval call for "eval"
This commit is contained in:
parent
08571f0914
commit
0655572f64
8
bin/emqx
8
bin/emqx
|
@ -481,7 +481,13 @@ case "${COMMAND}" in
|
||||||
shift
|
shift
|
||||||
if [ "$IS_ELIXIR" = "yes" ]
|
if [ "$IS_ELIXIR" = "yes" ]
|
||||||
then
|
then
|
||||||
relx_nodetool "eval-elixir" "$@"
|
"$REL_DIR/elixir" \
|
||||||
|
--hidden \
|
||||||
|
--cookie "$COOKIE" \
|
||||||
|
--boot "$REL_DIR/start_clean" \
|
||||||
|
--boot-var RELEASE_LIB "$ERTS_LIB_DIR" \
|
||||||
|
--vm-args "$(latest_vm_args 'EMQX_NODE__NAME')"\
|
||||||
|
--rpc-eval "$NAME" "$@"
|
||||||
else
|
else
|
||||||
relx_nodetool "eval" "$@"
|
relx_nodetool "eval" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
19
bin/nodetool
19
bin/nodetool
|
@ -126,25 +126,6 @@ do(Args) ->
|
||||||
io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]),
|
io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]),
|
||||||
halt(1)
|
halt(1)
|
||||||
end;
|
end;
|
||||||
["eval-elixir" | ListOfArgs] ->
|
|
||||||
JoinedArgs = string:join(ListOfArgs, " "),
|
|
||||||
case rpc:call(TargetNode, 'Elixir.Code', eval_string, [JoinedArgs]) of
|
|
||||||
{Value, []} ->
|
|
||||||
%% Since we are in Erlang land, we ask Elixir to
|
|
||||||
%% format the result as well:
|
|
||||||
case rpc:call(TargetNode, 'Elixir.Kernel', inspect, [Value, [{pretty, true}]]) of
|
|
||||||
{badrpc, Reason} ->
|
|
||||||
io:format(
|
|
||||||
"Warning: failed to format term with Elixir syntax. Reason: ~p~n"
|
|
||||||
"Warning: falling back to Erlang syntax:~n"
|
|
||||||
"~p~n", [Reason, Value]);
|
|
||||||
PrettyStr ->
|
|
||||||
io:format("~s~n", [PrettyStr])
|
|
||||||
end;
|
|
||||||
{badrpc, Reason} ->
|
|
||||||
io:format("RPC to ~p failed: ~p~n", [TargetNode, Reason]),
|
|
||||||
halt(1)
|
|
||||||
end;
|
|
||||||
Other ->
|
Other ->
|
||||||
io:format("Other: ~p~n", [Other]),
|
io:format("Other: ~p~n", [Other]),
|
||||||
io:format("Usage: nodetool chkconfig|getpid|ping|stop|rpc|rpc_infinity|rpcterms|eval|cold_eval [Terms] [RPC]\n")
|
io:format("Usage: nodetool chkconfig|getpid|ping|stop|rpc|rpc_infinity|rpcterms|eval|cold_eval [Terms] [RPC]\n")
|
||||||
|
|
Loading…
Reference in New Issue