Merge pull request #1135 from emqtt/develop
Add 'listeners restart/stop' Ctl command
This commit is contained in:
commit
c015f72a90
5
Makefile
5
Makefile
|
@ -39,6 +39,11 @@ CT_OPTS = -cover test/ct.cover.spec -erl_args -name emqttd_ct@127.0.0.1
|
||||||
|
|
||||||
COVER = true
|
COVER = true
|
||||||
|
|
||||||
|
PLT_APPS = sasl asn1 ssl syntax_tools runtime_tools crypto xmerl os_mon inets public_key ssl lager compiler mnesia
|
||||||
|
DIALYZER_DIRS := ebin/
|
||||||
|
DIALYZER_OPTS := --verbose --statistics -Werror_handling \
|
||||||
|
-Wrace_conditions #-Wunmatched_returns
|
||||||
|
|
||||||
include erlang.mk
|
include erlang.mk
|
||||||
|
|
||||||
app:: rebar.config
|
app:: rebar.config
|
||||||
|
|
|
@ -477,8 +477,38 @@ listeners([]) ->
|
||||||
end, Info)
|
end, Info)
|
||||||
end, esockd:listeners());
|
end, esockd:listeners());
|
||||||
|
|
||||||
|
listeners(["restart", Proto, ListenOn]) ->
|
||||||
|
ListenOn1 = case string:tokens(ListenOn, ":") of
|
||||||
|
[Port] -> list_to_integer(Port);
|
||||||
|
[IP, Port] -> {IP, list_to_integer(Port)}
|
||||||
|
end,
|
||||||
|
case emqttd_app:restart_listener({list_to_atom(Proto), ListenOn1, []}) of
|
||||||
|
{ok, _Pid} ->
|
||||||
|
io:format("Restart ~s listen on ~s successfully.~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn)]);
|
||||||
|
{error, Error} ->
|
||||||
|
io:format("Failed to restart ~s listen on ~s, error:~p~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn) ,Error])
|
||||||
|
end;
|
||||||
|
|
||||||
|
listeners(["stop", Proto, ListenOn]) ->
|
||||||
|
ListenOn1 = case string:tokens(ListenOn, ":") of
|
||||||
|
[Port] -> list_to_integer(Port);
|
||||||
|
[IP, Port] -> {IP, list_to_integer(Port)}
|
||||||
|
end,
|
||||||
|
case emqttd_app:stop_listener({list_to_atom(Proto), ListenOn1, []}) of
|
||||||
|
ok ->
|
||||||
|
io:format("Stop ~s on ~s successfully.~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn)]);
|
||||||
|
{error, Error} ->
|
||||||
|
io:format("Failed to stop ~s on ~s, error:~p~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn) ,Error])
|
||||||
|
end;
|
||||||
|
|
||||||
listeners(_) ->
|
listeners(_) ->
|
||||||
?PRINT_CMD("listeners", "List listeners").
|
?USAGE([{"listeners", "List listeners"},
|
||||||
|
{"listeners restart <Proto> <Port>", "Restart a listener port"},
|
||||||
|
{"listeners stop <Proto> <Port>", "Stop a listener port"}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Dump ETS
|
%% Dump ETS
|
||||||
|
|
|
@ -75,6 +75,8 @@ run([CmdS|Args]) ->
|
||||||
_ -> ok
|
_ -> ok
|
||||||
catch
|
catch
|
||||||
_:Reason ->
|
_:Reason ->
|
||||||
|
io:format("Reason:~p, get_stacktrace:~p~n",
|
||||||
|
[Reason, erlang:get_stacktrace()]),
|
||||||
{error, Reason}
|
{error, Reason}
|
||||||
end;
|
end;
|
||||||
[] ->
|
[] ->
|
||||||
|
|
Loading…
Reference in New Issue