Merge branch 'develop' of https://github.com/emqtt/emqttd into develop
This commit is contained in:
commit
6f28c36fef
|
@ -477,8 +477,38 @@ listeners([]) ->
|
||||||
end, Info)
|
end, Info)
|
||||||
end, esockd:listeners());
|
end, esockd:listeners());
|
||||||
|
|
||||||
|
listeners(["reopen", Proto, ListenOn1]) ->
|
||||||
|
ListenOn = case string:tokens(ListenOn1, ":") of
|
||||||
|
[Port] -> list_to_integer(Port);
|
||||||
|
[IP, Port] -> {IP, list_to_integer(Port)}
|
||||||
|
end,
|
||||||
|
case emqttd_app:restart_listener({list_to_atom(Proto), ListenOn, []}) of
|
||||||
|
{ok, _Pid} ->
|
||||||
|
io:format("Reopen ~p listen on ~p successfully.~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn1)]);
|
||||||
|
{error, Error} ->
|
||||||
|
io:format("Failed to reopen ~p listen on ~p, error:~p~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn1) ,Error])
|
||||||
|
end;
|
||||||
|
|
||||||
|
listeners(["close", Proto, ListenOn1]) ->
|
||||||
|
ListenOn = case string:tokens(ListenOn1, ":") of
|
||||||
|
[Port] -> list_to_integer(Port);
|
||||||
|
[IP, Port] -> {IP, list_to_integer(Port)}
|
||||||
|
end,
|
||||||
|
case emqttd_app:stop_listener({list_to_atom(Proto), ListenOn, []}) of
|
||||||
|
ok ->
|
||||||
|
io:format("Close ~p on ~p successfully.~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn1)]);
|
||||||
|
{error, Error} ->
|
||||||
|
io:format("Failed to close ~p on ~p, error:~p~n",
|
||||||
|
[list_to_atom(Proto), list_to_atom(ListenOn1) ,Error])
|
||||||
|
end;
|
||||||
|
|
||||||
listeners(_) ->
|
listeners(_) ->
|
||||||
?PRINT_CMD("listeners", "List listeners").
|
?USAGE([{"listeners", "List listeners"},
|
||||||
|
{"listeners reopen <Proto> <Port>", "Reopen a listener port"},
|
||||||
|
{"listeners close <Proto> <Port>", "Close a listener port"}]).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Dump ETS
|
%% Dump ETS
|
||||||
|
|
|
@ -64,14 +64,24 @@ cast(Msg) -> gen_server:cast(?SERVER, Msg).
|
||||||
|
|
||||||
%% @doc Run a command
|
%% @doc Run a command
|
||||||
-spec(run([string()]) -> any()).
|
-spec(run([string()]) -> any()).
|
||||||
run([]) -> usage();
|
run([]) -> usage(), ok;
|
||||||
|
|
||||||
run(["help"]) -> usage();
|
run(["help"]) -> usage(), ok;
|
||||||
|
|
||||||
run([CmdS|Args]) ->
|
run([CmdS|Args]) ->
|
||||||
case lookup(list_to_atom(CmdS)) of
|
case lookup(list_to_atom(CmdS)) of
|
||||||
[{Mod, Fun}] -> Mod:Fun(Args);
|
[{Mod, Fun}] ->
|
||||||
[] -> usage()
|
try Mod:Fun(Args) of
|
||||||
|
_ -> ok
|
||||||
|
catch
|
||||||
|
_:Reason ->
|
||||||
|
io:format("Reason:~p, get_stacktrace:~p~n",
|
||||||
|
[Reason, erlang:get_stacktrace()]),
|
||||||
|
{error, Reason}
|
||||||
|
end;
|
||||||
|
[] ->
|
||||||
|
usage(),
|
||||||
|
{error, cmd_not_found}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
%% @doc Lookup a command
|
%% @doc Lookup a command
|
||||||
|
|
Loading…
Reference in New Issue