-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(machine_boot): use shared list of reboot apps and add bridges to reboot list #11309
Merged
thalesmg
merged 4 commits into
emqx:release-51
from
thalesmg:fix-machine-boot-reboot-r51-20230719
Jul 20, 2023
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b9b11d8
fix(machine_boot): use shared list of reboot apps and add bridges to …
thalesmg 89ea40a
refactor: apply review remarks
thalesmg 77e2d85
fix: add emqx_durable_storage to app list
thalesmg 6cd5038
fix(machine_boot): ensure `emqx_bridge` starts after its companion apps
thalesmg File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
%% -*- mode: erlang; -*- | ||
#{ | ||
%% must always be of type `load' | ||
db_apps => | ||
[ | ||
mnesia_rocksdb, | ||
mnesia, | ||
mria, | ||
ekka | ||
], | ||
system_apps => | ||
[ | ||
kernel, | ||
sasl, | ||
crypto, | ||
public_key, | ||
asn1, | ||
syntax_tools, | ||
ssl, | ||
os_mon, | ||
inets, | ||
compiler, | ||
runtime_tools, | ||
redbug, | ||
xmerl, | ||
{hocon, load}, | ||
telemetry | ||
], | ||
%% must always be of type `load' | ||
common_business_apps => | ||
[ | ||
emqx, | ||
emqx_conf, | ||
|
||
esasl, | ||
observer_cli, | ||
tools, | ||
covertool, | ||
%% started by emqx_machine | ||
system_monitor, | ||
emqx_utils, | ||
emqx_http_lib, | ||
emqx_resource, | ||
emqx_connector, | ||
emqx_authn, | ||
emqx_authz, | ||
emqx_auto_subscribe, | ||
emqx_gateway, | ||
emqx_gateway_stomp, | ||
emqx_gateway_mqttsn, | ||
emqx_gateway_coap, | ||
emqx_gateway_lwm2m, | ||
emqx_gateway_exproto, | ||
emqx_exhook, | ||
emqx_bridge, | ||
emqx_bridge_mqtt, | ||
emqx_bridge_http, | ||
emqx_rule_engine, | ||
emqx_modules, | ||
emqx_management, | ||
emqx_dashboard, | ||
emqx_retainer, | ||
emqx_prometheus, | ||
emqx_psk, | ||
emqx_slow_subs, | ||
emqx_mongodb, | ||
emqx_redis, | ||
emqx_mysql, | ||
emqx_plugins, | ||
quicer, | ||
bcrypt, | ||
jq, | ||
observer | ||
], | ||
%% must always be of type `load' | ||
ee_business_apps => | ||
[ | ||
emqx_license, | ||
emqx_enterprise, | ||
emqx_bridge_kafka, | ||
emqx_bridge_pulsar, | ||
emqx_bridge_gcp_pubsub, | ||
emqx_bridge_cassandra, | ||
emqx_bridge_opents, | ||
emqx_bridge_clickhouse, | ||
emqx_bridge_dynamo, | ||
emqx_bridge_hstreamdb, | ||
emqx_bridge_influxdb, | ||
emqx_bridge_iotdb, | ||
emqx_bridge_matrix, | ||
emqx_bridge_mongodb, | ||
emqx_bridge_mysql, | ||
emqx_bridge_pgsql, | ||
emqx_bridge_redis, | ||
emqx_bridge_rocketmq, | ||
emqx_bridge_tdengine, | ||
emqx_bridge_timescale, | ||
emqx_bridge_sqlserver, | ||
emqx_oracle, | ||
emqx_bridge_oracle, | ||
emqx_bridge_rabbitmq, | ||
emqx_schema_registry, | ||
emqx_eviction_agent, | ||
emqx_node_rebalance, | ||
emqx_ft | ||
], | ||
%% must always be of type `load' | ||
ce_business_apps => | ||
[emqx_telemetry] | ||
}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"]), | ||
ieQu1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{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) -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really need a ./configure step for the build... |
||
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()], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should split ee_business_apps to a different apps' prive dir. apps/emqx_enteriprise/priv/
In order to don't include enterprise in community version.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emqx_machine_boot:basic_reboot_apps()
on ce already mentions some ee apps on master.But I agree that we can further improve it later.