Merge pull request #11309 from thalesmg/fix-machine-boot-reboot-r51-20230719
fix(machine_boot): use shared list of reboot apps and add bridges to reboot list
This commit is contained in:
commit
54efc04a6f
2
Makefile
2
Makefile
|
@ -295,7 +295,7 @@ $(foreach tt,$(ALL_ELIXIR_TGZS),$(eval $(call gen-elixir-tgz-target,$(tt))))
|
||||||
|
|
||||||
.PHONY: fmt
|
.PHONY: fmt
|
||||||
fmt: $(REBAR)
|
fmt: $(REBAR)
|
||||||
@$(SCRIPTS)/erlfmt -w '{apps,lib-ee}/*/{src,include,test}/**/*.{erl,hrl,app.src}'
|
@$(SCRIPTS)/erlfmt -w '{apps,lib-ee}/*/{src,include,priv,test}/**/*.{erl,hrl,app.src,eterm}'
|
||||||
@$(SCRIPTS)/erlfmt -w 'rebar.config.erl'
|
@$(SCRIPTS)/erlfmt -w 'rebar.config.erl'
|
||||||
@mix format
|
@mix format
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
ecql
|
ecql
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
clickhouse
|
clickhouse
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
erlcloud
|
erlcloud
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge_http,
|
|
||||||
ehttpc
|
ehttpc
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -598,6 +598,7 @@ start_cluster(Cluster) ->
|
||||||
end,
|
end,
|
||||||
Cluster
|
Cluster
|
||||||
),
|
),
|
||||||
|
NumNodes = length(Nodes),
|
||||||
on_exit(fun() ->
|
on_exit(fun() ->
|
||||||
emqx_utils:pmap(
|
emqx_utils:pmap(
|
||||||
fun(N) ->
|
fun(N) ->
|
||||||
|
@ -607,6 +608,11 @@ start_cluster(Cluster) ->
|
||||||
Nodes
|
Nodes
|
||||||
)
|
)
|
||||||
end),
|
end),
|
||||||
|
{ok, _} = snabbkaffe:block_until(
|
||||||
|
%% -1 because only those that join the first node will emit the event.
|
||||||
|
?match_n_events(NumNodes - 1, #{?snk_kind := emqx_machine_boot_apps_started}),
|
||||||
|
30_000
|
||||||
|
),
|
||||||
Nodes.
|
Nodes.
|
||||||
|
|
||||||
wait_for_cluster_rpc(Node) ->
|
wait_for_cluster_rpc(Node) ->
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
hstreamdb_erl
|
hstreamdb_erl
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{description, "EMQX HTTP Bridge and Connector Application"},
|
{description, "EMQX HTTP Bridge and Connector Application"},
|
||||||
{vsn, "0.1.1"},
|
{vsn, "0.1.1"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx_connector, emqx_resource, emqx_bridge, ehttpc]},
|
{applications, [kernel, stdlib, emqx_connector, emqx_resource, ehttpc]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
influxdb
|
influxdb
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge_http,
|
|
||||||
%% for module emqx_connector_http
|
%% for module emqx_connector_http
|
||||||
emqx_connector
|
emqx_connector
|
||||||
]},
|
]},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
telemetry,
|
telemetry,
|
||||||
wolff,
|
wolff,
|
||||||
brod,
|
brod,
|
||||||
|
|
|
@ -1071,13 +1071,14 @@ cluster(Config) ->
|
||||||
Cluster = emqx_common_test_helpers:emqx_cluster(
|
Cluster = emqx_common_test_helpers:emqx_cluster(
|
||||||
[core, core],
|
[core, core],
|
||||||
[
|
[
|
||||||
{apps, [emqx_conf, emqx_bridge, emqx_rule_engine, emqx_bridge_kafka]},
|
{apps, [emqx_conf, emqx_rule_engine, emqx_bridge_kafka, emqx_bridge]},
|
||||||
{listener_ports, []},
|
{listener_ports, []},
|
||||||
{peer_mod, PeerModule},
|
{peer_mod, PeerModule},
|
||||||
{priv_data_dir, PrivDataDir},
|
{priv_data_dir, PrivDataDir},
|
||||||
{load_schema, true},
|
{load_schema, true},
|
||||||
{start_autocluster, true},
|
{start_autocluster, true},
|
||||||
{schema_mod, emqx_enterprise_schema},
|
{schema_mod, emqx_enterprise_schema},
|
||||||
|
{load_apps, [emqx_machine]},
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx) ->
|
(emqx) ->
|
||||||
application:set_env(emqx, boot_modules, [broker, router]),
|
application:set_env(emqx, boot_modules, [broker, router]),
|
||||||
|
@ -1901,6 +1902,7 @@ t_cluster_node_down(Config) ->
|
||||||
?check_trace(
|
?check_trace(
|
||||||
begin
|
begin
|
||||||
{_N2, Opts2} = lists:nth(2, Cluster),
|
{_N2, Opts2} = lists:nth(2, Cluster),
|
||||||
|
NumNodes = length(Cluster),
|
||||||
Nodes =
|
Nodes =
|
||||||
[N1, N2 | _] =
|
[N1, N2 | _] =
|
||||||
lists:map(
|
lists:map(
|
||||||
|
@ -1925,6 +1927,11 @@ t_cluster_node_down(Config) ->
|
||||||
15_000
|
15_000
|
||||||
),
|
),
|
||||||
wait_for_cluster_rpc(N2),
|
wait_for_cluster_rpc(N2),
|
||||||
|
{ok, _} = snabbkaffe:block_until(
|
||||||
|
%% -1 because only those that join the first node will emit the event.
|
||||||
|
?match_n_events(NumNodes - 1, #{?snk_kind := emqx_machine_boot_apps_started}),
|
||||||
|
30_000
|
||||||
|
),
|
||||||
erpc:call(N2, fun() -> {ok, _} = create_bridge(Config) end),
|
erpc:call(N2, fun() -> {ok, _} = create_bridge(Config) end),
|
||||||
{ok, _} = snabbkaffe:receive_events(SRef0),
|
{ok, _} = snabbkaffe:receive_events(SRef0),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
|
@ -1980,7 +1987,7 @@ t_cluster_node_down(Config) ->
|
||||||
?assertEqual(NPartitions, map_size(Assignments)),
|
?assertEqual(NPartitions, map_size(Assignments)),
|
||||||
NumPublished = ets:info(TId, size),
|
NumPublished = ets:info(TId, size),
|
||||||
%% All published messages are eventually received.
|
%% All published messages are eventually received.
|
||||||
Published = receive_published(#{n => NumPublished, timeout => 3_000}),
|
Published = receive_published(#{n => NumPublished, timeout => 10_000}),
|
||||||
ct:pal("published:\n ~p", [Published]),
|
ct:pal("published:\n ~p", [Published]),
|
||||||
ok
|
ok
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource
|
||||||
emqx_bridge
|
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_connector,
|
emqx_connector,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
emqx_mongodb
|
emqx_mongodb
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{application, emqx_bridge_mqtt, [
|
{application, emqx_bridge_mqtt, [
|
||||||
{description, "EMQX MQTT Broker Bridge"},
|
{description, "EMQX MQTT Broker Bridge"},
|
||||||
{vsn, "0.1.2"},
|
{vsn, "0.1.3"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx,
|
emqx,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
emqtt
|
emqtt
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_connector,
|
emqx_connector,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
emqx_mysql
|
emqx_mysql
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
opentsdb
|
opentsdb
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
emqx_oracle
|
emqx_oracle
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
{applications, [
|
{applications, [
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource
|
||||||
emqx_bridge
|
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
pulsar
|
pulsar
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -547,6 +547,7 @@ start_cluster(Cluster) ->
|
||||||
emqx_common_test_helpers:start_slave(Name, Opts)
|
emqx_common_test_helpers:start_slave(Name, Opts)
|
||||||
|| {Name, Opts} <- Cluster
|
|| {Name, Opts} <- Cluster
|
||||||
],
|
],
|
||||||
|
NumNodes = length(Nodes),
|
||||||
on_exit(fun() ->
|
on_exit(fun() ->
|
||||||
emqx_utils:pmap(
|
emqx_utils:pmap(
|
||||||
fun(N) ->
|
fun(N) ->
|
||||||
|
@ -556,6 +557,11 @@ start_cluster(Cluster) ->
|
||||||
Nodes
|
Nodes
|
||||||
)
|
)
|
||||||
end),
|
end),
|
||||||
|
{ok, _} = snabbkaffe:block_until(
|
||||||
|
%% -1 because only those that join the first node will emit the event.
|
||||||
|
?match_n_events(NumNodes - 1, #{?snk_kind := emqx_machine_boot_apps_started}),
|
||||||
|
30_000
|
||||||
|
),
|
||||||
Nodes.
|
Nodes.
|
||||||
|
|
||||||
kill_resource_managers() ->
|
kill_resource_managers() ->
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
ecql,
|
|
||||||
rabbit_common,
|
rabbit_common,
|
||||||
amqp_client
|
amqp_client
|
||||||
]},
|
]},
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_connector,
|
emqx_connector,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
emqx_redis
|
emqx_redis
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{description, "EMQX Enterprise RocketMQ Bridge"},
|
{description, "EMQX Enterprise RocketMQ Bridge"},
|
||||||
{vsn, "0.1.3"},
|
{vsn, "0.1.3"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx_resource, emqx_bridge, rocketmq]},
|
{applications, [kernel, stdlib, emqx_resource, rocketmq]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{description, "EMQX Enterprise SQL Server Bridge"},
|
{description, "EMQX Enterprise SQL Server Bridge"},
|
||||||
{vsn, "0.1.2"},
|
{vsn, "0.1.2"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx_resource, emqx_bridge, odbc]},
|
{applications, [kernel, stdlib, emqx_resource, odbc]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
kernel,
|
kernel,
|
||||||
stdlib,
|
stdlib,
|
||||||
emqx_resource,
|
emqx_resource,
|
||||||
emqx_bridge,
|
|
||||||
tdengine
|
tdengine
|
||||||
]},
|
]},
|
||||||
{env, []},
|
{env, []},
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{description, "EMQX Enterprise TimescaleDB Bridge"},
|
{description, "EMQX Enterprise TimescaleDB Bridge"},
|
||||||
{vsn, "0.1.2"},
|
{vsn, "0.1.2"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, emqx_resource, emqx_bridge]},
|
{applications, [kernel, stdlib, emqx_resource]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -0,0 +1,111 @@
|
||||||
|
%% -*- 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_durable_storage,
|
||||||
|
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]
|
||||||
|
}.
|
|
@ -16,6 +16,7 @@
|
||||||
-module(emqx_machine_boot).
|
-module(emqx_machine_boot).
|
||||||
|
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-include_lib("emqx/include/logger.hrl").
|
||||||
|
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||||
|
|
||||||
-export([post_boot/0]).
|
-export([post_boot/0]).
|
||||||
-export([stop_apps/0, ensure_apps_started/0]).
|
-export([stop_apps/0, ensure_apps_started/0]).
|
||||||
|
@ -24,7 +25,6 @@
|
||||||
-export([stop_port_apps/0]).
|
-export([stop_port_apps/0]).
|
||||||
|
|
||||||
-dialyzer({no_match, [basic_reboot_apps/0]}).
|
-dialyzer({no_match, [basic_reboot_apps/0]}).
|
||||||
-dialyzer({no_match, [basic_reboot_apps_edition/1]}).
|
|
||||||
|
|
||||||
-ifdef(TEST).
|
-ifdef(TEST).
|
||||||
-export([sorted_reboot_apps/1, reboot_apps/0]).
|
-export([sorted_reboot_apps/1, reboot_apps/0]).
|
||||||
|
@ -94,7 +94,8 @@ stop_one_app(App) ->
|
||||||
|
|
||||||
ensure_apps_started() ->
|
ensure_apps_started() ->
|
||||||
?SLOG(notice, #{msg => "(re)starting_emqx_apps"}),
|
?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) ->
|
start_one_app(App) ->
|
||||||
?SLOG(debug, #{msg => "starting_app", app => App}),
|
?SLOG(debug, #{msg => "starting_app", app => App}),
|
||||||
|
@ -128,44 +129,39 @@ reboot_apps() ->
|
||||||
BaseRebootApps ++ ConfigApps.
|
BaseRebootApps ++ ConfigApps.
|
||||||
|
|
||||||
basic_reboot_apps() ->
|
basic_reboot_apps() ->
|
||||||
?BASIC_REBOOT_APPS ++
|
PrivDir = code:priv_dir(emqx_machine),
|
||||||
[
|
RebootListPath = filename:join([PrivDir, "reboot_lists.eterm"]),
|
||||||
emqx_prometheus,
|
{ok, [
|
||||||
emqx_modules,
|
#{
|
||||||
emqx_dashboard,
|
common_business_apps := CommonBusinessApps,
|
||||||
emqx_connector,
|
ee_business_apps := EEBusinessApps,
|
||||||
emqx_gateway,
|
ce_business_apps := CEBusinessApps
|
||||||
emqx_resource,
|
}
|
||||||
emqx_rule_engine,
|
]} = file:consult(RebootListPath),
|
||||||
emqx_bridge,
|
EditionSpecificApps =
|
||||||
emqx_management,
|
case emqx_release:edition() of
|
||||||
emqx_retainer,
|
ee -> EEBusinessApps;
|
||||||
emqx_exhook,
|
ce -> CEBusinessApps;
|
||||||
emqx_authn,
|
_ -> []
|
||||||
emqx_authz,
|
end,
|
||||||
emqx_slow_subs,
|
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
||||||
emqx_auto_subscribe,
|
?BASIC_REBOOT_APPS ++ (BusinessApps -- excluded_apps()).
|
||||||
emqx_plugins,
|
|
||||||
emqx_psk
|
|
||||||
] ++ basic_reboot_apps_edition(emqx_release:edition()).
|
|
||||||
|
|
||||||
basic_reboot_apps_edition(ce) ->
|
excluded_apps() ->
|
||||||
[emqx_telemetry];
|
OptionalApps = [bcrypt, jq, observer],
|
||||||
basic_reboot_apps_edition(ee) ->
|
[system_monitor, observer_cli] ++
|
||||||
[
|
[App || App <- OptionalApps, not is_app(App)].
|
||||||
emqx_license,
|
|
||||||
emqx_s3,
|
is_app(Name) ->
|
||||||
emqx_ft,
|
case application:load(Name) of
|
||||||
emqx_eviction_agent,
|
ok -> true;
|
||||||
emqx_node_rebalance,
|
{error, {already_loaded, _}} -> true;
|
||||||
emqx_schema_registry
|
_ -> false
|
||||||
];
|
end.
|
||||||
%% unexcepted edition, should not happen
|
|
||||||
basic_reboot_apps_edition(_) ->
|
|
||||||
[].
|
|
||||||
|
|
||||||
sorted_reboot_apps() ->
|
sorted_reboot_apps() ->
|
||||||
Apps = [{App, app_deps(App)} || App <- reboot_apps()],
|
Apps0 = [{App, app_deps(App)} || App <- reboot_apps()],
|
||||||
|
Apps = inject_bridge_deps(Apps0),
|
||||||
sorted_reboot_apps(Apps).
|
sorted_reboot_apps(Apps).
|
||||||
|
|
||||||
app_deps(App) ->
|
app_deps(App) ->
|
||||||
|
@ -174,6 +170,25 @@ app_deps(App) ->
|
||||||
{ok, List} -> lists:filter(fun(A) -> lists:member(A, reboot_apps()) end, List)
|
{ok, List} -> lists:filter(fun(A) -> lists:member(A, reboot_apps()) end, List)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
%% `emqx_bridge' is special in that it needs all the bridges apps to
|
||||||
|
%% be started before it, so that, when it loads the bridges from
|
||||||
|
%% configuration, the bridge app and its dependencies need to be up.
|
||||||
|
inject_bridge_deps(RebootAppDeps) ->
|
||||||
|
BridgeApps = [
|
||||||
|
App
|
||||||
|
|| {App, _Deps} <- RebootAppDeps,
|
||||||
|
lists:prefix("emqx_bridge_", atom_to_list(App))
|
||||||
|
],
|
||||||
|
lists:map(
|
||||||
|
fun
|
||||||
|
({emqx_bridge, Deps0}) when is_list(Deps0) ->
|
||||||
|
{emqx_bridge, Deps0 ++ BridgeApps};
|
||||||
|
(App) ->
|
||||||
|
App
|
||||||
|
end,
|
||||||
|
RebootAppDeps
|
||||||
|
).
|
||||||
|
|
||||||
sorted_reboot_apps(Apps) ->
|
sorted_reboot_apps(Apps) ->
|
||||||
G = digraph:new(),
|
G = digraph:new(),
|
||||||
try
|
try
|
||||||
|
|
|
@ -364,11 +364,7 @@ cluster(Config) ->
|
||||||
{load_schema, true},
|
{load_schema, true},
|
||||||
{start_autocluster, true},
|
{start_autocluster, true},
|
||||||
{schema_mod, emqx_enterprise_schema},
|
{schema_mod, emqx_enterprise_schema},
|
||||||
%% need to restart schema registry app in the tests so
|
{load_apps, [emqx_machine]},
|
||||||
%% that it re-registers the config handler that is lost
|
|
||||||
%% when emqx_conf restarts during join.
|
|
||||||
{env, [{emqx_machine, applications, [emqx_schema_registry]}]},
|
|
||||||
{load_apps, [emqx_machine | ?APPS]},
|
|
||||||
{env_handler, fun
|
{env_handler, fun
|
||||||
(emqx) ->
|
(emqx) ->
|
||||||
application:set_env(emqx, boot_modules, [broker, router]),
|
application:set_env(emqx, boot_modules, [broker, router]),
|
||||||
|
@ -388,6 +384,7 @@ start_cluster(Cluster) ->
|
||||||
emqx_common_test_helpers:start_slave(Name, Opts)
|
emqx_common_test_helpers:start_slave(Name, Opts)
|
||||||
|| {Name, Opts} <- Cluster
|
|| {Name, Opts} <- Cluster
|
||||||
],
|
],
|
||||||
|
NumNodes = length(Nodes),
|
||||||
on_exit(fun() ->
|
on_exit(fun() ->
|
||||||
emqx_utils:pmap(
|
emqx_utils:pmap(
|
||||||
fun(N) ->
|
fun(N) ->
|
||||||
|
@ -397,7 +394,11 @@ start_cluster(Cluster) ->
|
||||||
Nodes
|
Nodes
|
||||||
)
|
)
|
||||||
end),
|
end),
|
||||||
erpc:multicall(Nodes, mria_rlog, wait_for_shards, [[?SCHEMA_REGISTRY_SHARD], 30_000]),
|
{ok, _} = snabbkaffe:block_until(
|
||||||
|
%% -1 because only those that join the first node will emit the event.
|
||||||
|
?match_n_events(NumNodes - 1, #{?snk_kind := emqx_machine_boot_apps_started}),
|
||||||
|
30_000
|
||||||
|
),
|
||||||
Nodes.
|
Nodes.
|
||||||
|
|
||||||
wait_for_cluster_rpc(Node) ->
|
wait_for_cluster_rpc(Node) ->
|
||||||
|
@ -658,7 +659,7 @@ t_cluster_serde_build(Config) ->
|
||||||
Nodes = [N1, N2 | _] = start_cluster(Cluster),
|
Nodes = [N1, N2 | _] = start_cluster(Cluster),
|
||||||
NumNodes = length(Nodes),
|
NumNodes = length(Nodes),
|
||||||
wait_for_cluster_rpc(N2),
|
wait_for_cluster_rpc(N2),
|
||||||
?assertEqual(
|
?assertMatch(
|
||||||
ok,
|
ok,
|
||||||
erpc:call(N2, emqx_schema_registry, add_schema, [SerdeName, Schema])
|
erpc:call(N2, emqx_schema_registry, add_schema, [SerdeName, Schema])
|
||||||
),
|
),
|
||||||
|
@ -687,7 +688,7 @@ t_cluster_serde_build(Config) ->
|
||||||
{ok, SRef1} = snabbkaffe:subscribe(
|
{ok, SRef1} = snabbkaffe:subscribe(
|
||||||
?match_event(#{?snk_kind := schema_registry_serdes_deleted}),
|
?match_event(#{?snk_kind := schema_registry_serdes_deleted}),
|
||||||
NumNodes,
|
NumNodes,
|
||||||
5_000
|
10_000
|
||||||
),
|
),
|
||||||
?assertEqual(
|
?assertEqual(
|
||||||
ok,
|
ok,
|
||||||
|
|
171
mix.exs
171
mix.exs
|
@ -297,6 +297,7 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
[
|
[
|
||||||
applications: applications(edition_type),
|
applications: applications(edition_type),
|
||||||
skip_mode_validation_for: [
|
skip_mode_validation_for: [
|
||||||
|
:emqx_mix,
|
||||||
:emqx_gateway,
|
:emqx_gateway,
|
||||||
:emqx_gateway_stomp,
|
:emqx_gateway_stomp,
|
||||||
:emqx_gateway_mqttsn,
|
:emqx_gateway_mqttsn,
|
||||||
|
@ -316,7 +317,10 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
:emqx_auto_subscribe,
|
:emqx_auto_subscribe,
|
||||||
:emqx_slow_subs,
|
:emqx_slow_subs,
|
||||||
:emqx_plugins,
|
:emqx_plugins,
|
||||||
:emqx_ft
|
:emqx_ft,
|
||||||
|
:emqx_s3,
|
||||||
|
:emqx_durable_storage,
|
||||||
|
:rabbit_common
|
||||||
],
|
],
|
||||||
steps: steps,
|
steps: steps,
|
||||||
strip_beams: false
|
strip_beams: false
|
||||||
|
@ -326,137 +330,54 @@ defmodule EMQXUmbrella.MixProject do
|
||||||
end
|
end
|
||||||
|
|
||||||
def applications(edition_type) do
|
def applications(edition_type) do
|
||||||
system_apps = [
|
{:ok,
|
||||||
crypto: :permanent,
|
|
||||||
public_key: :permanent,
|
|
||||||
asn1: :permanent,
|
|
||||||
syntax_tools: :permanent,
|
|
||||||
ssl: :permanent,
|
|
||||||
os_mon: :permanent,
|
|
||||||
inets: :permanent,
|
|
||||||
compiler: :permanent,
|
|
||||||
runtime_tools: :permanent,
|
|
||||||
redbug: :permanent,
|
|
||||||
xmerl: :permanent,
|
|
||||||
hocon: :load,
|
|
||||||
telemetry: :permanent
|
|
||||||
]
|
|
||||||
|
|
||||||
db_apps =
|
|
||||||
if enable_rocksdb?() do
|
|
||||||
[:mnesia_rocksdb]
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end ++
|
|
||||||
[
|
[
|
||||||
:mnesia,
|
%{
|
||||||
:mria,
|
db_apps: db_apps,
|
||||||
:ekka
|
system_apps: system_apps,
|
||||||
]
|
common_business_apps: common_business_apps,
|
||||||
|
ee_business_apps: ee_business_apps,
|
||||||
|
ce_business_apps: ce_business_apps
|
||||||
|
}
|
||||||
|
]} = :file.consult("apps/emqx_machine/priv/reboot_lists.eterm")
|
||||||
|
|
||||||
business_apps =
|
edition_specific_apps =
|
||||||
[
|
if edition_type == :enterprise do
|
||||||
:emqx,
|
ee_business_apps
|
||||||
:emqx_conf,
|
|
||||||
:esasl,
|
|
||||||
:observer_cli,
|
|
||||||
:tools,
|
|
||||||
:covertool,
|
|
||||||
: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,
|
|
||||||
:emqx_mix
|
|
||||||
] ++
|
|
||||||
if enable_quicer?() do
|
|
||||||
[:quicer]
|
|
||||||
else
|
else
|
||||||
[]
|
ce_business_apps
|
||||||
end ++
|
|
||||||
if enable_bcrypt?() do
|
|
||||||
[:bcrypt]
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end ++
|
|
||||||
if enable_jq?() do
|
|
||||||
[:jq]
|
|
||||||
else
|
|
||||||
[]
|
|
||||||
end ++
|
|
||||||
if(is_app(:observer),
|
|
||||||
do: [:observer],
|
|
||||||
else: []
|
|
||||||
) ++
|
|
||||||
case edition_type do
|
|
||||||
:enterprise ->
|
|
||||||
[
|
|
||||||
: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
|
|
||||||
]
|
|
||||||
|
|
||||||
_ ->
|
|
||||||
[:emqx_telemetry]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
system_apps ++
|
business_apps = common_business_apps ++ edition_specific_apps
|
||||||
Enum.map(db_apps, &{&1, :load}) ++
|
|
||||||
[emqx_machine: :permanent] ++
|
excluded_apps = excluded_apps()
|
||||||
Enum.map(business_apps, &{&1, :load})
|
|
||||||
|
system_apps =
|
||||||
|
Enum.map(system_apps, fn app ->
|
||||||
|
if is_atom(app), do: {app, :permanent}, else: app
|
||||||
|
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 is_app(name) do
|
defp excluded_apps() do
|
||||||
|
%{
|
||||||
|
mnesia_rocksdb: enable_rocksdb?(),
|
||||||
|
quicer: enable_quicer?(),
|
||||||
|
bcrypt: enable_bcrypt?(),
|
||||||
|
jq: enable_jq?(),
|
||||||
|
observer: is_app?(:observer)
|
||||||
|
}
|
||||||
|
|> Enum.reject(&elem(&1, 1))
|
||||||
|
|> Enum.map(&elem(&1, 0))
|
||||||
|
end
|
||||||
|
|
||||||
|
defp is_app?(name) do
|
||||||
case Application.load(name) do
|
case Application.load(name) do
|
||||||
:ok ->
|
:ok ->
|
||||||
true
|
true
|
||||||
|
|
137
rebar.config.erl
137
rebar.config.erl
|
@ -386,84 +386,37 @@ overlay_vars_pkg(pkg) ->
|
||||||
].
|
].
|
||||||
|
|
||||||
relx_apps(ReleaseType, Edition) ->
|
relx_apps(ReleaseType, Edition) ->
|
||||||
SystemApps =
|
{ok, [
|
||||||
[
|
#{
|
||||||
kernel,
|
db_apps := DBApps,
|
||||||
sasl,
|
system_apps := SystemApps,
|
||||||
crypto,
|
common_business_apps := CommonBusinessApps,
|
||||||
public_key,
|
ee_business_apps := EEBusinessApps,
|
||||||
asn1,
|
ce_business_apps := CEBusinessApps
|
||||||
syntax_tools,
|
}
|
||||||
ssl,
|
]} = file:consult("apps/emqx_machine/priv/reboot_lists.eterm"),
|
||||||
os_mon,
|
EditionSpecificApps =
|
||||||
inets,
|
case Edition of
|
||||||
compiler,
|
ee -> EEBusinessApps;
|
||||||
runtime_tools,
|
ce -> CEBusinessApps
|
||||||
redbug,
|
end,
|
||||||
xmerl,
|
BusinessApps = CommonBusinessApps ++ EditionSpecificApps,
|
||||||
{hocon, load},
|
ExcludedApps = excluded_apps(ReleaseType),
|
||||||
telemetry
|
|
||||||
],
|
|
||||||
DBApps =
|
|
||||||
[mnesia_rocksdb || is_rocksdb_supported()] ++
|
|
||||||
[
|
|
||||||
mnesia,
|
|
||||||
mria,
|
|
||||||
ekka
|
|
||||||
],
|
|
||||||
BusinessApps =
|
|
||||||
[
|
|
||||||
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 || is_quicer_supported()] ++
|
|
||||||
[bcrypt || provide_bcrypt_release(ReleaseType)] ++
|
|
||||||
%% Started automatically when needed (only needs to be started when the
|
|
||||||
%% port implementation is used)
|
|
||||||
[jq || is_jq_supported()] ++
|
|
||||||
[observer || is_app(observer)] ++
|
|
||||||
relx_apps_per_edition(Edition),
|
|
||||||
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)].
|
||||||
|
|
||||||
|
excluded_apps(ReleaseType) ->
|
||||||
|
OptionalApps = [
|
||||||
|
{quicer, is_quicer_supported()},
|
||||||
|
{bcrypt, provide_bcrypt_release(ReleaseType)},
|
||||||
|
{jq, is_jq_supported()},
|
||||||
|
{observer, is_app(observer)},
|
||||||
|
{mnesia_rocksdb, is_rocksdb_supported()}
|
||||||
|
],
|
||||||
|
[App || {App, false} <- OptionalApps].
|
||||||
|
|
||||||
is_app(Name) ->
|
is_app(Name) ->
|
||||||
case application:load(Name) of
|
case application:load(Name) of
|
||||||
|
@ -472,40 +425,6 @@ is_app(Name) ->
|
||||||
_ -> false
|
_ -> false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
relx_apps_per_edition(ee) ->
|
|
||||||
[
|
|
||||||
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
|
|
||||||
];
|
|
||||||
relx_apps_per_edition(ce) ->
|
|
||||||
[emqx_telemetry].
|
|
||||||
|
|
||||||
relx_overlay(ReleaseType, Edition) ->
|
relx_overlay(ReleaseType, Edition) ->
|
||||||
[
|
[
|
||||||
{mkdir, "log/"},
|
{mkdir, "log/"},
|
||||||
|
|
Loading…
Reference in New Issue