feat(quic): support stop/start quic listeners.

This commit is contained in:
William Yang 2021-05-07 13:43:48 +02:00
parent 06f9674ce3
commit 14057c033d
4 changed files with 9 additions and 4 deletions

View File

@ -239,10 +239,10 @@ reboot() ->
-ifdef(EMQX_ENTERPRISE).
default_started_applications() ->
[gproc, esockd, ranch, cowboy, ekka, emqx].
[gproc, esockd, ranch, cowboy, ekka, quicer, emqx].
-else.
default_started_applications() ->
[gproc, esockd, ranch, cowboy, ekka, emqx, emqx_modules].
[gproc, esockd, ranch, cowboy, ekka, quicer, emqx, emqx_modules].
-endif.
%%--------------------------------------------------------------------

View File

@ -49,6 +49,9 @@ start(_Type, _Args) ->
ok = emqx_plugins:init(),
_ = emqx_plugins:load(),
_ = start_ce_modules(),
%% @fixme unsure why we need this.
quicer_nif:open_lib(),
quicer_nif:reg_open(),
emqx_boot:is_enabled(listeners) andalso (ok = emqx_listeners:start()),
register(emqx, self()),
ok = emqx_alarm_handler:load(),

View File

@ -141,7 +141,7 @@ start_listener(Proto, ListenOn, Options) when Proto == https; Proto == wss ->
start_http_listener(fun cowboy:start_tls/3, 'mqtt:wss', ListenOn,
ranch_opts(Options), ws_opts(Options));
%% MQTT over QUIC
%% Start MQTT/QUIC listener
start_listener(quic, ListenOn, Options) ->
SSLOpts = proplists:get_value(ssl_options, Options),
ListenOpts = [ {cert, proplists:get_value(certfile, SSLOpts)}
@ -253,6 +253,8 @@ stop_listener(Proto, ListenOn, _Opts) when Proto == http; Proto == ws ->
cowboy:stop_listener(ws_name('mqtt:ws', ListenOn));
stop_listener(Proto, ListenOn, _Opts) when Proto == https; Proto == wss ->
cowboy:stop_listener(ws_name('mqtt:wss', ListenOn));
stop_listener(quic, _ListenOn, _Opts) ->
quicer:stop_listener('mqtt:quic');
stop_listener(Proto, ListenOn, _Opts) ->
esockd:close(Proto, ListenOn).

View File

@ -54,7 +54,7 @@
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.5.1"}}}
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}}
, {quicer, {git, "https://github.com/qzhuyan/quic.git", {branch, "demo/3"}}}
, {quicer, {git, "https://github.com/qzhuyan/quic.git", {branch, "dev/william/main-prepare-emqx"}}}
]}.
{xref_ignores,