EMQX failed to start when the listening port was occupied (#3354)
This commit is contained in:
parent
d49f4118fe
commit
9ba938b9d9
|
@ -44,17 +44,16 @@
|
|||
start() ->
|
||||
lists:foreach(fun start_listener/1, emqx:get_env(listeners, [])).
|
||||
|
||||
-spec(start_listener(listener()) -> {ok, pid()} | {error, term()}).
|
||||
-spec(start_listener(listener()) -> ok).
|
||||
start_listener({Proto, ListenOn, Options}) ->
|
||||
StartRet = start_listener(Proto, ListenOn, Options),
|
||||
case StartRet of
|
||||
case start_listener(Proto, ListenOn, Options) of
|
||||
{ok, _} -> io:format("Start mqtt:~s listener on ~s successfully.~n",
|
||||
[Proto, format(ListenOn)]);
|
||||
{error, Reason} ->
|
||||
io:format(standard_error, "Failed to start mqtt:~s listener on ~s - ~0p~n!",
|
||||
[Proto, format(ListenOn), Reason])
|
||||
end,
|
||||
StartRet.
|
||||
[Proto, format(ListenOn), Reason]),
|
||||
error(Reason)
|
||||
end.
|
||||
|
||||
%% Start MQTT/TCP listener
|
||||
-spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()])
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
-include("emqx.hrl").
|
||||
-include("emqx_mqtt.hrl").
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
|
||||
all() -> emqx_ct:all(?MODULE).
|
||||
|
||||
|
@ -37,7 +38,7 @@ end_per_suite(_Config) ->
|
|||
|
||||
t_start_stop_listeners(_) ->
|
||||
ok = emqx_listeners:start(),
|
||||
{error, _} = emqx_listeners:start_listener({ws,{"127.0.0.1", 8083}, []}),
|
||||
?assertException(error, _, emqx_listeners:start_listener({ws,{"127.0.0.1", 8083}, []})),
|
||||
ok = emqx_listeners:stop().
|
||||
|
||||
t_restart_listeners(_) ->
|
||||
|
|
Loading…
Reference in New Issue