Merge pull request #9091 from zmstone/1003-no-shutdown-logging-to-remote-node-when-rpc
fix(emqx): emqx:shutdown should not log to remote node
This commit is contained in:
commit
124f9795cd
|
@ -227,6 +227,7 @@ shutdown() ->
|
||||||
shutdown(normal).
|
shutdown(normal).
|
||||||
|
|
||||||
shutdown(Reason) ->
|
shutdown(Reason) ->
|
||||||
|
ok = emqx_misc:maybe_mute_rpc_log(),
|
||||||
?LOG(critical, "emqx shutdown for ~s", [Reason]),
|
?LOG(critical, "emqx shutdown for ~s", [Reason]),
|
||||||
on_shutdown(Reason),
|
on_shutdown(Reason),
|
||||||
_ = emqx_plugins:unload(),
|
_ = emqx_plugins:unload(),
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
|
|
||||||
-export([ merge_opts/2
|
-export([ merge_opts/2
|
||||||
, maybe_apply/2
|
, maybe_apply/2
|
||||||
|
, maybe_mute_rpc_log/0
|
||||||
, compose/1
|
, compose/1
|
||||||
, compose/2
|
, compose/2
|
||||||
, run_fold/3
|
, run_fold/3
|
||||||
|
@ -444,6 +445,27 @@ do_parallel_map(Fun, List) ->
|
||||||
PidList
|
PidList
|
||||||
).
|
).
|
||||||
|
|
||||||
|
%% @doc Call this function to avoid logs printed to RPC caller node.
|
||||||
|
-spec maybe_mute_rpc_log() -> ok.
|
||||||
|
maybe_mute_rpc_log() ->
|
||||||
|
GlNode = node(group_leader()),
|
||||||
|
maybe_mute_rpc_log(GlNode).
|
||||||
|
|
||||||
|
maybe_mute_rpc_log(Node) when Node =:= node() ->
|
||||||
|
%% do nothing, this is a local call
|
||||||
|
ok;
|
||||||
|
maybe_mute_rpc_log(Node) ->
|
||||||
|
case atom_to_list(Node) of
|
||||||
|
"remsh_" ++ _ ->
|
||||||
|
%% this is either an upgrade script or nodetool
|
||||||
|
%% do nothing, the log may go to the 'emqx' command line console
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
%% otherwise set group leader to local node
|
||||||
|
_ = group_leader(whereis(init), self()),
|
||||||
|
ok
|
||||||
|
end.
|
||||||
|
|
||||||
-ifdef(TEST).
|
-ifdef(TEST).
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue