|
@@ -46,24 +46,15 @@
|
|
|
|
|
|
|
|
start(_Type, _Args) ->
|
|
start(_Type, _Args) ->
|
|
|
ok = maybe_load_config(),
|
|
ok = maybe_load_config(),
|
|
|
- ok = set_backtrace_depth(),
|
|
|
|
|
- print_otp_version_warning(),
|
|
|
|
|
- print_banner(),
|
|
|
|
|
%% Load application first for ekka_mnesia scanner
|
|
%% Load application first for ekka_mnesia scanner
|
|
|
- _ = 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 = maybe_start_quicer(),
|
|
|
{ok, Sup} = emqx_sup:start_link(),
|
|
{ok, Sup} = emqx_sup:start_link(),
|
|
|
|
|
+ ok = maybe_start_listeners(),
|
|
|
ok = start_autocluster(),
|
|
ok = start_autocluster(),
|
|
|
- % ok = emqx_plugins:init(),
|
|
|
|
|
- _ = emqx_plugins:load(),
|
|
|
|
|
- _ = start_ce_modules(),
|
|
|
|
|
- emqx_boot:is_enabled(listeners) andalso (ok = emqx_listeners:start()),
|
|
|
|
|
- register(emqx, self()),
|
|
|
|
|
ok = emqx_alarm_handler:load(),
|
|
ok = emqx_alarm_handler:load(),
|
|
|
- print_vsn(),
|
|
|
|
|
|
|
+ register(emqx, self()),
|
|
|
{ok, Sup}.
|
|
{ok, Sup}.
|
|
|
|
|
|
|
|
prep_stop(_State) ->
|
|
prep_stop(_State) ->
|
|
@@ -89,52 +80,22 @@ maybe_load_config() ->
|
|
|
emqx_config:init_load(emqx_schema, ConfFiles)
|
|
emqx_config:init_load(emqx_schema, ConfFiles)
|
|
|
end.
|
|
end.
|
|
|
|
|
|
|
|
-set_backtrace_depth() ->
|
|
|
|
|
- Depth = emqx_config:get([node, backtrace_depth]),
|
|
|
|
|
- _ = erlang:system_flag(backtrace_depth, Depth),
|
|
|
|
|
- ok.
|
|
|
|
|
-
|
|
|
|
|
--ifndef(EMQX_ENTERPRISE).
|
|
|
|
|
-load_ce_modules() ->
|
|
|
|
|
- application:load(emqx_modules).
|
|
|
|
|
-start_ce_modules() ->
|
|
|
|
|
- application:ensure_all_started(emqx_modules).
|
|
|
|
|
--else.
|
|
|
|
|
-load_ce_modules() ->
|
|
|
|
|
- ok.
|
|
|
|
|
-start_ce_modules() ->
|
|
|
|
|
- ok.
|
|
|
|
|
--endif.
|
|
|
|
|
-
|
|
|
|
|
-%%--------------------------------------------------------------------
|
|
|
|
|
-%% Print Banner
|
|
|
|
|
-%%--------------------------------------------------------------------
|
|
|
|
|
-
|
|
|
|
|
--if(?OTP_RELEASE> 22).
|
|
|
|
|
-print_otp_version_warning() -> ok.
|
|
|
|
|
--else.
|
|
|
|
|
-print_otp_version_warning() ->
|
|
|
|
|
- ?ULOG("WARNING: Running on Erlang/OTP version ~p. Recommended: 23~n",
|
|
|
|
|
- [?OTP_RELEASE]).
|
|
|
|
|
--endif. % OTP_RELEASE
|
|
|
|
|
-
|
|
|
|
|
--ifndef(TEST).
|
|
|
|
|
-
|
|
|
|
|
-print_banner() ->
|
|
|
|
|
- ?ULOG("Starting ~s on node ~s~n", [?APP, node()]).
|
|
|
|
|
-
|
|
|
|
|
-print_vsn() ->
|
|
|
|
|
- ?ULOG("~s ~s is running now!~n", [get_description(), get_release()]).
|
|
|
|
|
-
|
|
|
|
|
--else. % TEST
|
|
|
|
|
-
|
|
|
|
|
-print_vsn() ->
|
|
|
|
|
- ok.
|
|
|
|
|
-
|
|
|
|
|
-print_banner() ->
|
|
|
|
|
- ok.
|
|
|
|
|
|
|
+maybe_start_listeners() ->
|
|
|
|
|
+ case emqx_boot:is_enabled(listeners) of
|
|
|
|
|
+ true ->
|
|
|
|
|
+ ok = emqx_listeners:start();
|
|
|
|
|
+ false ->
|
|
|
|
|
+ ok
|
|
|
|
|
+ end.
|
|
|
|
|
|
|
|
--endif. % TEST
|
|
|
|
|
|
|
+maybe_start_quicer() ->
|
|
|
|
|
+ case os:getenv("EMQX_NO_QUIC") of
|
|
|
|
|
+ X when X =:= "1" orelse X =:= "true" ->
|
|
|
|
|
+ ok;
|
|
|
|
|
+ _ ->
|
|
|
|
|
+ {ok, _} = application:ensure_all_started(quicer),
|
|
|
|
|
+ ok
|
|
|
|
|
+ end.
|
|
|
|
|
|
|
|
get_description() ->
|
|
get_description() ->
|
|
|
{ok, Descr0} = application:get_key(?APP, description),
|
|
{ok, Descr0} = application:get_key(?APP, description),
|
|
@@ -164,9 +125,6 @@ get_release() ->
|
|
|
release_in_macro() ->
|
|
release_in_macro() ->
|
|
|
element(2, ?EMQX_RELEASE).
|
|
element(2, ?EMQX_RELEASE).
|
|
|
|
|
|
|
|
-%%--------------------------------------------------------------------
|
|
|
|
|
-%% Autocluster
|
|
|
|
|
-%%--------------------------------------------------------------------
|
|
|
|
|
start_autocluster() ->
|
|
start_autocluster() ->
|
|
|
ekka:callback(prepare, fun emqx:shutdown/1),
|
|
ekka:callback(prepare, fun emqx:shutdown/1),
|
|
|
ekka:callback(reboot, fun emqx:reboot/0),
|
|
ekka:callback(reboot, fun emqx:reboot/0),
|