|
|
@@ -16,6 +16,7 @@
|
|
|
-module(emqx_machine_boot).
|
|
|
|
|
|
-include_lib("emqx/include/logger.hrl").
|
|
|
+-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
|
|
|
|
|
-export([post_boot/0]).
|
|
|
-export([stop_apps/0, ensure_apps_started/0]).
|
|
|
@@ -24,7 +25,6 @@
|
|
|
-export([stop_port_apps/0]).
|
|
|
|
|
|
-dialyzer({no_match, [basic_reboot_apps/0]}).
|
|
|
--dialyzer({no_match, [basic_reboot_apps_edition/1]}).
|
|
|
|
|
|
-ifdef(TEST).
|
|
|
-export([sorted_reboot_apps/1, reboot_apps/0]).
|
|
|
@@ -94,7 +94,8 @@ stop_one_app(App) ->
|
|
|
|
|
|
ensure_apps_started() ->
|
|
|
?SLOG(notice, #{msg => "(re)starting_emqx_apps"}),
|
|
|
- lists:foreach(fun start_one_app/1, sorted_reboot_apps()).
|
|
|
+ lists:foreach(fun start_one_app/1, sorted_reboot_apps()),
|
|
|
+ ?tp(emqx_machine_boot_apps_started, #{}).
|
|
|
|
|
|
start_one_app(App) ->
|
|
|
?SLOG(debug, #{msg => "starting_app", app => App}),
|
|
|
@@ -128,41 +129,62 @@ reboot_apps() ->
|
|
|
BaseRebootApps ++ ConfigApps.
|
|
|
|
|
|
basic_reboot_apps() ->
|
|
|
- ?BASIC_REBOOT_APPS ++
|
|
|
- [
|
|
|
- emqx_prometheus,
|
|
|
- emqx_modules,
|
|
|
- emqx_dashboard,
|
|
|
- emqx_connector,
|
|
|
- emqx_gateway,
|
|
|
- emqx_resource,
|
|
|
- emqx_rule_engine,
|
|
|
- emqx_bridge,
|
|
|
- emqx_management,
|
|
|
- emqx_retainer,
|
|
|
- emqx_exhook,
|
|
|
- emqx_authn,
|
|
|
- emqx_authz,
|
|
|
- emqx_slow_subs,
|
|
|
- emqx_auto_subscribe,
|
|
|
- emqx_plugins,
|
|
|
- emqx_psk
|
|
|
- ] ++ basic_reboot_apps_edition(emqx_release:edition()).
|
|
|
-
|
|
|
-basic_reboot_apps_edition(ce) ->
|
|
|
- [emqx_telemetry];
|
|
|
-basic_reboot_apps_edition(ee) ->
|
|
|
- [
|
|
|
- emqx_license,
|
|
|
- emqx_s3,
|
|
|
- emqx_ft,
|
|
|
- emqx_eviction_agent,
|
|
|
- emqx_node_rebalance,
|
|
|
- emqx_schema_registry
|
|
|
- ];
|
|
|
-%% unexcepted edition, should not happen
|
|
|
-basic_reboot_apps_edition(_) ->
|
|
|
- [].
|
|
|
+ PrivDir = code:priv_dir(emqx_machine),
|
|
|
+ RebootListPath = filename:join([PrivDir, "reboot_lists.eterm"]),
|
|
|
+ {ok, [
|
|
|
+ #{
|
|
|
+ common_business_apps := CommonBusinessApps0,
|
|
|
+ ee_business_apps := EEBusinessApps,
|
|
|
+ ce_business_apps := CEBusinessApps
|
|
|
+ }
|
|
|
+ ]} = file:consult(RebootListPath),
|
|
|
+ Filters0 = maps:from_list([
|
|
|
+ {App, is_app(App)}
|
|
|
+ || App <- [quicer, bcrypt, jq, observer]
|
|
|
+ ]),
|
|
|
+ CommonBusinessApps =
|
|
|
+ filter(
|
|
|
+ CommonBusinessApps0,
|
|
|
+ %% We don't need to restart these
|
|
|
+ Filters0#{
|
|
|
+ system_monitor => false,
|
|
|
+ observer => false,
|
|
|
+ quicer => false
|
|
|
+ }
|
|
|
+ ),
|
|
|
+ EditionSpecificApps =
|
|
|
+ case emqx_release:edition() of
|
|
|
+ ee -> EEBusinessApps;
|
|
|
+ ce -> CEBusinessApps;
|
|
|
+ _ -> []
|
|
|
+ end,
|
|
|
+ BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
|
|
+ ?BASIC_REBOOT_APPS ++ BusinessApps.
|
|
|
+
|
|
|
+filter(AppList, Filters) ->
|
|
|
+ lists:foldr(
|
|
|
+ fun(App, Acc) ->
|
|
|
+ AppName =
|
|
|
+ case App of
|
|
|
+ {Name, _Type} -> Name;
|
|
|
+ Name when is_atom(Name) -> Name
|
|
|
+ end,
|
|
|
+ ShouldKeep = maps:get(AppName, Filters, true),
|
|
|
+ case ShouldKeep of
|
|
|
+ true -> [App | Acc];
|
|
|
+ false -> Acc
|
|
|
+ end
|
|
|
+ end,
|
|
|
+ [],
|
|
|
+ AppList
|
|
|
+ ).
|
|
|
+
|
|
|
+is_app(Name) ->
|
|
|
+ case application:load(Name) of
|
|
|
+ ok -> true;
|
|
|
+ {error, {already_loaded, _}} -> true;
|
|
|
+ _ -> false
|
|
|
+ end.
|
|
|
|
|
|
sorted_reboot_apps() ->
|
|
|
Apps = [{App, app_deps(App)} || App <- reboot_apps()],
|