fix(mgmt_cli): Do not doulbe print listener stop results

This commit is contained in:
Zaiming Shi 2021-02-14 20:16:42 +01:00
parent 153977609e
commit 2d79c870c1
1 changed files with 8 additions and 9 deletions

View File

@ -549,18 +549,17 @@ listeners(["stop", _Proto, ListenOn]) ->
listeners(_) -> listeners(_) ->
emqx_ctl:usage([{"listeners", "List listeners"}, emqx_ctl:usage([{"listeners", "List listeners"},
{"listeners stop <Proto> <Port>", "Stop a listener"}]). {"listeners stop <Identifier>", "Stop a listener"},
{"listeners stop <Proto> <Port>", "Stop a listener"}
]).
stop_listener(false, Input) -> stop_listener(false, Input) ->
emqx_ctl:print("No such listener ~p~n", [Input]); emqx_ctl:print("No such listener ~p~n", [Input]);
stop_listener(#{listen_on := ListenOn} = Listener, _Input) -> stop_listener(#{} = Listener, _Input) ->
ID = emqx_listeners:identifier(Listener), %% Discard reason here, reasons are io:format logged to group leader
case emqx_listeners:stop_listener(Listener) of %% in case of emqx_ctl RPC call, it's logged to the remore node.
ok -> _ = emqx_listeners:stop_listener(Listener),
emqx_ctl:print("Stop ~s listener on ~s successfully.~n", [ID, ListenOn]); ok.
{error, Error} ->
emqx_ctl:print("Failed to stop ~s listener on ~s, error:~p~n", [ID, ListenOn, Error])
end.
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% @doc data Command %% @doc data Command