feat(quic): conditionally build/start quicer app
This commit is contained in:
parent
6adb76cf27
commit
1f20bae392
|
@ -20,7 +20,6 @@
|
||||||
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
|
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
|
||||||
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
|
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
|
||||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
|
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
|
||||||
, {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.5"}}}
|
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{plugins, [rebar3_proper]}.
|
{plugins, [rebar3_proper]}.
|
||||||
|
|
|
@ -1,11 +1,30 @@
|
||||||
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}},
|
IsCentos6 = fun() ->
|
||||||
AddBcrypt = fun(C) ->
|
case file:read_file("/etc/centos-release") of
|
||||||
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
{ok, <<"CentOS release 6", _/binary >>} ->
|
||||||
Deps = [Bcrypt | Deps0],
|
true;
|
||||||
lists:keystore(deps, 1, C, {deps, Deps})
|
_ ->
|
||||||
end,
|
false
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
case os:type() of
|
IsWin32 = fun() ->
|
||||||
{win32, _} -> CONFIG;
|
win32 =:= element(1, os:type())
|
||||||
_ -> AddBcrypt(CONFIG)
|
end,
|
||||||
end.
|
|
||||||
|
IsQuicSupp = fun() ->
|
||||||
|
not (IsCentos6() orelse IsWin32() orelse
|
||||||
|
false =/= os:getenv("EMQX_BUILD_WITHOUT_QUIC")
|
||||||
|
)
|
||||||
|
end,
|
||||||
|
|
||||||
|
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}},
|
||||||
|
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {branch, "main"}}},
|
||||||
|
|
||||||
|
ExtraDeps = fun(C) ->
|
||||||
|
{deps, Deps0} = lists:keyfind(deps, 1, C),
|
||||||
|
Deps = Deps0 ++ [Bcrypt || not IsWin32()] ++
|
||||||
|
[ Quicer || IsQuicSupp()],
|
||||||
|
lists:keystore(deps, 1, C, {deps, Deps})
|
||||||
|
end,
|
||||||
|
|
||||||
|
ExtraDeps(CONFIG).
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{vsn, "5.0.0"}, % strict semver, bump manually!
|
{vsn, "5.0.0"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel,stdlib,gproc,gen_rpc,esockd,cowboy,sasl,os_mon,quicer,jiffy]},
|
{applications, [kernel,stdlib,gproc,gen_rpc,esockd,cowboy,sasl,os_mon,jiffy]},
|
||||||
{mod, {emqx_app,[]}},
|
{mod, {emqx_app,[]}},
|
||||||
{env, []},
|
{env, []},
|
||||||
{licenses, ["Apache-2.0"]},
|
{licenses, ["Apache-2.0"]},
|
||||||
|
|
|
@ -49,6 +49,8 @@ start(_Type, _Args) ->
|
||||||
_ = load_ce_modules(),
|
_ = load_ce_modules(),
|
||||||
ekka:start(),
|
ekka:start(),
|
||||||
ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity),
|
ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity),
|
||||||
|
false == os:getenv("EMQX_NO_QUIC")
|
||||||
|
andalso application:ensure_all_started(quicer),
|
||||||
{ok, Sup} = emqx_sup:start_link(),
|
{ok, Sup} = emqx_sup:start_link(),
|
||||||
ok = start_autocluster(),
|
ok = start_autocluster(),
|
||||||
% ok = emqx_plugins:init(),
|
% ok = emqx_plugins:init(),
|
||||||
|
|
|
@ -106,6 +106,8 @@ format_listen_on(ListenOn) -> format(ListenOn).
|
||||||
start_listener(#{proto := Proto, name := Name, listen_on := ListenOn, opts := Options}) ->
|
start_listener(#{proto := Proto, name := Name, listen_on := ListenOn, opts := Options}) ->
|
||||||
ID = identifier(Proto, Name),
|
ID = identifier(Proto, Name),
|
||||||
case start_listener(Proto, ListenOn, Options) of
|
case start_listener(Proto, ListenOn, Options) of
|
||||||
|
{ok, skipped} ->
|
||||||
|
console_print("Start ~s listener on ~s skpped.~n", [ID, format(ListenOn)]);
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
console_print("Start ~s listener on ~s successfully.~n", [ID, format(ListenOn)]);
|
console_print("Start ~s listener on ~s successfully.~n", [ID, format(ListenOn)]);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
@ -123,7 +125,7 @@ console_print(_Fmt, _Args) -> ok.
|
||||||
|
|
||||||
%% Start MQTT/TCP listener
|
%% Start MQTT/TCP listener
|
||||||
-spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()])
|
-spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()])
|
||||||
-> {ok, pid()} | {error, term()}).
|
-> {ok, pid() | skipped} | {error, term()}).
|
||||||
start_listener(tcp, ListenOn, Options) ->
|
start_listener(tcp, ListenOn, Options) ->
|
||||||
start_mqtt_listener('mqtt:tcp', ListenOn, Options);
|
start_mqtt_listener('mqtt:tcp', ListenOn, Options);
|
||||||
|
|
||||||
|
@ -143,6 +145,9 @@ start_listener(Proto, ListenOn, Options) when Proto == https; Proto == wss ->
|
||||||
|
|
||||||
%% Start MQTT/QUIC listener
|
%% Start MQTT/QUIC listener
|
||||||
start_listener(quic, ListenOn, Options) ->
|
start_listener(quic, ListenOn, Options) ->
|
||||||
|
IsQuicEnabled = false == os:getenv("EMQX_NO_QUIC"),
|
||||||
|
case [ A || {quicer, _, _} = A<-application:which_applications() ] of
|
||||||
|
[_] when IsQuicEnabled ->
|
||||||
%% @fixme unsure why we need reopen lib and reopen config.
|
%% @fixme unsure why we need reopen lib and reopen config.
|
||||||
quicer_nif:open_lib(),
|
quicer_nif:open_lib(),
|
||||||
quicer_nif:reg_open(),
|
quicer_nif:reg_open(),
|
||||||
|
@ -160,7 +165,12 @@ start_listener(quic, ListenOn, Options) ->
|
||||||
| Options
|
| Options
|
||||||
],
|
],
|
||||||
StreamOpts = [],
|
StreamOpts = [],
|
||||||
quicer:start_listener('mqtt:quic', ListenOn, {ListenOpts, ConnectionOpts, StreamOpts}).
|
quicer:start_listener('mqtt:quic', ListenOn, {ListenOpts, ConnectionOpts, StreamOpts});
|
||||||
|
[] ->
|
||||||
|
io:format(standard_error, "INFO: quicer application is unavailable/disabled~n",
|
||||||
|
[]),
|
||||||
|
{ok, skipped}
|
||||||
|
end.
|
||||||
|
|
||||||
replace(Opts, Key, Value) -> [{Key, Value} | proplists:delete(Key, Opts)].
|
replace(Opts, Key, Value) -> [{Key, Value} | proplists:delete(Key, Opts)].
|
||||||
|
|
||||||
|
|
|
@ -63,8 +63,6 @@
|
||||||
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
|
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
|
||||||
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.9.0"}}}
|
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.9.0"}}}
|
||||||
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}}
|
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}}
|
||||||
%, {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.5"}}}
|
|
||||||
, {quicer, {git, "https://github.com/emqx/quic.git", {branch, "main"}}}
|
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
{xref_ignores,
|
{xref_ignores,
|
||||||
|
|
|
@ -15,12 +15,14 @@ do(Dir, CONFIG) ->
|
||||||
bcrypt() ->
|
bcrypt() ->
|
||||||
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}.
|
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}.
|
||||||
|
|
||||||
|
quicer() ->
|
||||||
|
%% @todo use tag
|
||||||
|
{quicer, {git, "https://github.com/emqx/quic.git", {branch, "main"}}}.
|
||||||
|
|
||||||
deps(Config) ->
|
deps(Config) ->
|
||||||
{deps, OldDeps} = lists:keyfind(deps, 1, Config),
|
{deps, OldDeps} = lists:keyfind(deps, 1, Config),
|
||||||
MoreDeps = case provide_bcrypt_dep() of
|
MoreDeps = [bcrypt() || provide_bcrypt_dep()] ++
|
||||||
true -> [bcrypt()];
|
[quicer() || is_quicer_supported()],
|
||||||
false -> []
|
|
||||||
end,
|
|
||||||
{HasElixir, ExtraDeps} = extra_deps(),
|
{HasElixir, ExtraDeps} = extra_deps(),
|
||||||
{HasElixir, lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps ++ ExtraDeps})}.
|
{HasElixir, lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps ++ ExtraDeps})}.
|
||||||
|
|
||||||
|
@ -78,6 +80,24 @@ is_cover_enabled() ->
|
||||||
is_enterprise() ->
|
is_enterprise() ->
|
||||||
filelib:is_regular("EMQX_ENTERPRISE").
|
filelib:is_regular("EMQX_ENTERPRISE").
|
||||||
|
|
||||||
|
is_quicer_supported() ->
|
||||||
|
not (false =/= os:getenv("BUILD_WITHOUT_QUIC") orelse
|
||||||
|
is_win32() orelse is_centos_6()
|
||||||
|
).
|
||||||
|
|
||||||
|
is_centos_6() ->
|
||||||
|
%% reason:
|
||||||
|
%% glibc is too old
|
||||||
|
case file:read_file("/etc/centos-release") of
|
||||||
|
{ok, <<"CentOS release 6", _/binary >>} ->
|
||||||
|
true;
|
||||||
|
_ ->
|
||||||
|
false
|
||||||
|
end.
|
||||||
|
|
||||||
|
is_win32() ->
|
||||||
|
win32 =:= element(1, os:type()).
|
||||||
|
|
||||||
project_app_dirs() ->
|
project_app_dirs() ->
|
||||||
["apps/*"] ++
|
["apps/*"] ++
|
||||||
case is_enterprise() of
|
case is_enterprise() of
|
||||||
|
@ -242,7 +262,6 @@ relx_apps(ReleaseType) ->
|
||||||
, compiler
|
, compiler
|
||||||
, runtime_tools
|
, runtime_tools
|
||||||
, cuttlefish
|
, cuttlefish
|
||||||
, quicer
|
|
||||||
, emqx
|
, emqx
|
||||||
, {mnesia, load}
|
, {mnesia, load}
|
||||||
, {ekka, load}
|
, {ekka, load}
|
||||||
|
@ -263,6 +282,7 @@ relx_apps(ReleaseType) ->
|
||||||
, emqx_retainer
|
, emqx_retainer
|
||||||
, emqx_statsd
|
, emqx_statsd
|
||||||
]
|
]
|
||||||
|
++ [quicer || is_quicer_supported()]
|
||||||
++ [emqx_telemetry || not is_enterprise()]
|
++ [emqx_telemetry || not is_enterprise()]
|
||||||
++ [emqx_license || is_enterprise()]
|
++ [emqx_license || is_enterprise()]
|
||||||
++ [bcrypt || provide_bcrypt_release(ReleaseType)]
|
++ [bcrypt || provide_bcrypt_release(ReleaseType)]
|
||||||
|
|
Loading…
Reference in New Issue