refactor: apply review remarks
This commit is contained in:
parent
b9b11d8f4d
commit
89ea40a8b7
|
@ -133,25 +133,11 @@ basic_reboot_apps() ->
|
||||||
RebootListPath = filename:join([PrivDir, "reboot_lists.eterm"]),
|
RebootListPath = filename:join([PrivDir, "reboot_lists.eterm"]),
|
||||||
{ok, [
|
{ok, [
|
||||||
#{
|
#{
|
||||||
common_business_apps := CommonBusinessApps0,
|
common_business_apps := CommonBusinessApps,
|
||||||
ee_business_apps := EEBusinessApps,
|
ee_business_apps := EEBusinessApps,
|
||||||
ce_business_apps := CEBusinessApps
|
ce_business_apps := CEBusinessApps
|
||||||
}
|
}
|
||||||
]} = file:consult(RebootListPath),
|
]} = 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 =
|
EditionSpecificApps =
|
||||||
case emqx_release:edition() of
|
case emqx_release:edition() of
|
||||||
ee -> EEBusinessApps;
|
ee -> EEBusinessApps;
|
||||||
|
@ -159,25 +145,12 @@ basic_reboot_apps() ->
|
||||||
_ -> []
|
_ -> []
|
||||||
end,
|
end,
|
||||||
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
||||||
?BASIC_REBOOT_APPS ++ BusinessApps.
|
?BASIC_REBOOT_APPS ++ (BusinessApps -- excluded_apps()).
|
||||||
|
|
||||||
filter(AppList, Filters) ->
|
excluded_apps() ->
|
||||||
lists:foldr(
|
OptionalApps = [bcrypt, jq, observer],
|
||||||
fun(App, Acc) ->
|
[system_monitor, observer_cli] ++
|
||||||
AppName =
|
[App || App <- OptionalApps, not is_app(App)].
|
||||||
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) ->
|
is_app(Name) ->
|
||||||
case application:load(Name) of
|
case application:load(Name) of
|
||||||
|
|
49
mix.exs
49
mix.exs
|
@ -341,16 +341,6 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
}
|
}
|
||||||
]} = :file.consult("apps/emqx_machine/priv/reboot_lists.eterm")
|
]} = :file.consult("apps/emqx_machine/priv/reboot_lists.eterm")
|
||||||
|
|
||||||
db_apps = filter(db_apps, %{mnesia_rocksdb: enable_rocksdb?()})
|
|
||||||
|
|
||||||
common_business_apps =
|
|
||||||
filter(common_business_apps, %{
|
|
||||||
quicer: enable_quicer?(),
|
|
||||||
bcrypt: enable_bcrypt?(),
|
|
||||||
jq: enable_jq?(),
|
|
||||||
observer: is_app?(:observer)
|
|
||||||
})
|
|
||||||
|
|
||||||
edition_specific_apps =
|
edition_specific_apps =
|
||||||
if edition_type == :enterprise do
|
if edition_type == :enterprise do
|
||||||
ee_business_apps
|
ee_business_apps
|
||||||
|
@ -360,24 +350,31 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
|
|
||||||
business_apps = common_business_apps ++ edition_specific_apps
|
business_apps = common_business_apps ++ edition_specific_apps
|
||||||
|
|
||||||
Enum.map(system_apps, fn app ->
|
excluded_apps = excluded_apps()
|
||||||
if is_atom(app), do: {app, :permanent}, else: app
|
|
||||||
end) ++
|
system_apps =
|
||||||
Enum.map(db_apps, &{&1, :load}) ++
|
Enum.map(system_apps, fn app ->
|
||||||
[emqx_machine: :permanent] ++
|
if is_atom(app), do: {app, :permanent}, else: app
|
||||||
Enum.map(business_apps, &{&1, :load})
|
end)
|
||||||
|
|
||||||
|
db_apps = Enum.map(db_apps, &{&1, :load})
|
||||||
|
business_apps = Enum.map(business_apps, &{&1, :load})
|
||||||
|
|
||||||
|
[system_apps, db_apps, [emqx_machine: :permanent], business_apps]
|
||||||
|
|> List.flatten()
|
||||||
|
|> Keyword.reject(fn {app, _type} -> app in excluded_apps end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter(apps, filters) do
|
defp excluded_apps() do
|
||||||
Enum.filter(apps, fn app ->
|
%{
|
||||||
app_name =
|
mnesia_rocksdb: enable_rocksdb?(),
|
||||||
case app do
|
quicer: enable_quicer?(),
|
||||||
{app_name, _type} -> app_name
|
bcrypt: enable_bcrypt?(),
|
||||||
app_name when is_atom(app_name) -> app_name
|
jq: enable_jq?(),
|
||||||
end
|
observer: is_app?(:observer)
|
||||||
|
}
|
||||||
Map.get(filters, app_name, true)
|
|> Enum.reject(&elem(&1, 1))
|
||||||
end)
|
|> Enum.map(&elem(&1, 0))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp is_app?(name) do
|
defp is_app?(name) do
|
||||||
|
|
|
@ -388,45 +388,35 @@ overlay_vars_pkg(pkg) ->
|
||||||
relx_apps(ReleaseType, Edition) ->
|
relx_apps(ReleaseType, Edition) ->
|
||||||
{ok, [
|
{ok, [
|
||||||
#{
|
#{
|
||||||
db_apps := DBApps0,
|
db_apps := DBApps,
|
||||||
system_apps := SystemApps,
|
system_apps := SystemApps,
|
||||||
common_business_apps := CommonBusinessApps0,
|
common_business_apps := CommonBusinessApps,
|
||||||
ee_business_apps := EEBusinessApps,
|
ee_business_apps := EEBusinessApps,
|
||||||
ce_business_apps := CEBusinessApps
|
ce_business_apps := CEBusinessApps
|
||||||
}
|
}
|
||||||
]} = file:consult("apps/emqx_machine/priv/reboot_lists.eterm"),
|
]} = file:consult("apps/emqx_machine/priv/reboot_lists.eterm"),
|
||||||
DBApps = filter(DBApps0, #{mnesia_rocksdb => is_rocksdb_supported()}),
|
|
||||||
CommonBusinessApps =
|
|
||||||
filter(CommonBusinessApps0, #{
|
|
||||||
quicer => is_quicer_supported(),
|
|
||||||
bcrypt => provide_bcrypt_release(ReleaseType),
|
|
||||||
jq => is_jq_supported(),
|
|
||||||
observer => is_app(observer)
|
|
||||||
}),
|
|
||||||
EditionSpecificApps =
|
EditionSpecificApps =
|
||||||
case Edition of
|
case Edition of
|
||||||
ee -> EEBusinessApps;
|
ee -> EEBusinessApps;
|
||||||
ce -> CEBusinessApps
|
ce -> CEBusinessApps
|
||||||
end,
|
end,
|
||||||
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
||||||
|
ExcludedApps = excluded_apps(ReleaseType),
|
||||||
SystemApps ++
|
SystemApps ++
|
||||||
%% EMQX starts the DB and the business applications:
|
%% EMQX starts the DB and the business applications:
|
||||||
[{App, load} || App <- DBApps] ++
|
[{App, load} || App <- (DBApps -- ExcludedApps)] ++
|
||||||
[emqx_machine] ++
|
[emqx_machine] ++
|
||||||
[{App, load} || App <- BusinessApps].
|
[{App, load} || App <- (BusinessApps -- ExcludedApps)].
|
||||||
|
|
||||||
filter(AppList, Filters) ->
|
excluded_apps(ReleaseType) ->
|
||||||
lists:filter(
|
OptionalApps = [
|
||||||
fun(App) ->
|
{quicer, is_quicer_supported()},
|
||||||
AppName =
|
{bcrypt, provide_bcrypt_release(ReleaseType)},
|
||||||
case App of
|
{jq, is_jq_supported()},
|
||||||
{Name, _Type} -> Name;
|
{observer, is_app(observer)},
|
||||||
Name when is_atom(Name) -> Name
|
{mnesia_rocksdb, is_rocksdb_supported()}
|
||||||
end,
|
],
|
||||||
maps:get(AppName, Filters, true)
|
[App || {App, false} <- OptionalApps].
|
||||||
end,
|
|
||||||
AppList
|
|
||||||
).
|
|
||||||
|
|
||||||
is_app(Name) ->
|
is_app(Name) ->
|
||||||
case application:load(Name) of
|
case application:load(Name) of
|
||||||
|
|
Loading…
Reference in New Issue