Merge branch 'boot' into develop
This commit is contained in:
commit
594153c0fb
|
@ -35,10 +35,10 @@ start(_Type, _Args) ->
|
||||||
ok = emqx_modules:load(),
|
ok = emqx_modules:load(),
|
||||||
ok = emqx_plugins:init(),
|
ok = emqx_plugins:init(),
|
||||||
emqx_plugins:load(),
|
emqx_plugins:load(),
|
||||||
ok = emqx_listeners:start(),
|
emqx_boot:is_enabled(listeners)
|
||||||
|
andalso (ok = emqx_listeners:start()),
|
||||||
start_autocluster(),
|
start_autocluster(),
|
||||||
register(emqx, self()),
|
register(emqx, self()),
|
||||||
|
|
||||||
emqx_alarm_handler:load(),
|
emqx_alarm_handler:load(),
|
||||||
print_vsn(),
|
print_vsn(),
|
||||||
{ok, Sup}.
|
{ok, Sup}.
|
||||||
|
@ -46,7 +46,8 @@ start(_Type, _Args) ->
|
||||||
-spec(stop(State :: term()) -> term()).
|
-spec(stop(State :: term()) -> term()).
|
||||||
stop(_State) ->
|
stop(_State) ->
|
||||||
emqx_alarm_handler:unload(),
|
emqx_alarm_handler:unload(),
|
||||||
emqx_listeners:stop(),
|
emqx_boot:is_enabled(listeners)
|
||||||
|
andalso emqx_listeners:stop(),
|
||||||
emqx_modules:unload().
|
emqx_modules:unload().
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%
|
||||||
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
%% you may not use this file except in compliance with the License.
|
||||||
|
%% You may obtain a copy of the License at
|
||||||
|
%%
|
||||||
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%
|
||||||
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%% See the License for the specific language governing permissions and
|
||||||
|
%% limitations under the License.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(emqx_boot).
|
||||||
|
|
||||||
|
-export([is_enabled/1]).
|
||||||
|
|
||||||
|
-define(BOOT_MODULES, [router, broker, listeners]).
|
||||||
|
|
||||||
|
-spec(is_enabled(all|list(router|broker|listeners)) -> boolean()).
|
||||||
|
is_enabled(Mod) ->
|
||||||
|
(BootMods = boot_modules()) =:= all orelse lists:member(Mod, BootMods).
|
||||||
|
|
||||||
|
boot_modules() ->
|
||||||
|
application:get_env(emqx, boot_modules, ?BOOT_MODULES).
|
||||||
|
|
|
@ -62,18 +62,21 @@ stop_child(ChildId) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
init([]) ->
|
init([]) ->
|
||||||
%% Kernel Sup
|
|
||||||
KernelSup = child_spec(emqx_kernel_sup, supervisor),
|
KernelSup = child_spec(emqx_kernel_sup, supervisor),
|
||||||
%% Router Sup
|
|
||||||
RouterSup = child_spec(emqx_router_sup, supervisor),
|
RouterSup = child_spec(emqx_router_sup, supervisor),
|
||||||
%% Broker Sup
|
|
||||||
BrokerSup = child_spec(emqx_broker_sup, supervisor),
|
BrokerSup = child_spec(emqx_broker_sup, supervisor),
|
||||||
%% CM Sup
|
|
||||||
CMSup = child_spec(emqx_cm_sup, supervisor),
|
CMSup = child_spec(emqx_cm_sup, supervisor),
|
||||||
%% Sys Sup
|
|
||||||
SysSup = child_spec(emqx_sys_sup, supervisor),
|
SysSup = child_spec(emqx_sys_sup, supervisor),
|
||||||
{ok, {{one_for_all, 0, 1},
|
Childs = [KernelSup] ++
|
||||||
[KernelSup, RouterSup, BrokerSup, CMSup, SysSup]}}.
|
[RouterSup || emqx_boot:is_enabled(router)] ++
|
||||||
|
[BrokerSup || emqx_boot:is_enabled(broker)] ++
|
||||||
|
[CMSup || emqx_boot:is_enabled(broker)] ++
|
||||||
|
[SysSup],
|
||||||
|
SupFlags = #{strategy => one_for_all,
|
||||||
|
intensity => 0,
|
||||||
|
period => 1
|
||||||
|
},
|
||||||
|
{ok, {SupFlags, Childs}}.
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
|
|
|
@ -63,6 +63,7 @@ groups() ->
|
||||||
}].
|
}].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules([router, broker]),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([], fun set_special_configs/1),
|
emqx_ct_helpers:start_apps([], fun set_special_configs/1),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2019 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%
|
||||||
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
%% you may not use this file except in compliance with the License.
|
||||||
|
%% You may obtain a copy of the License at
|
||||||
|
%%
|
||||||
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%
|
||||||
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%% See the License for the specific language governing permissions and
|
||||||
|
%% limitations under the License.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
|
-module(emqx_boot_SUITE).
|
||||||
|
|
||||||
|
-compile(export_all).
|
||||||
|
-compile(nowarn_export_all).
|
||||||
|
|
||||||
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
|
t_is_enabled(_) ->
|
||||||
|
ok = application:set_env(emqx, boot_modules, all),
|
||||||
|
?assert(emqx_boot:is_enabled(router)),
|
||||||
|
?assert(emqx_boot:is_enabled(broker)),
|
||||||
|
?assert(emqx_boot:is_enabled(listeners)),
|
||||||
|
ok = application:set_env(emqx, boot_modules, [router]),
|
||||||
|
?assert(emqx_boot:is_enabled(router)),
|
||||||
|
?assertNot(emqx_boot:is_enabled(broker)),
|
||||||
|
?assertNot(emqx_boot:is_enabled(listeners)),
|
||||||
|
ok = application:set_env(emqx, boot_modules, [router, broker]),
|
||||||
|
?assert(emqx_boot:is_enabled(router)),
|
||||||
|
?assert(emqx_boot:is_enabled(broker)),
|
||||||
|
?assertNot(emqx_boot:is_enabled(listeners)),
|
||||||
|
ok = application:set_env(emqx, boot_modules, [router, broker, listeners]),
|
||||||
|
?assert(emqx_boot:is_enabled(router)),
|
||||||
|
?assert(emqx_boot:is_enabled(broker)),
|
||||||
|
?assert(emqx_boot:is_enabled(listeners)).
|
||||||
|
|
|
@ -49,6 +49,7 @@ groups() ->
|
||||||
}].
|
}].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules([router, broker]),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules([router, broker]),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,7 @@ groups() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules([]),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
@ -51,4 +52,3 @@ test(_) ->
|
||||||
io:format("Hello world").
|
io:format("Hello world").
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([emqx]),
|
emqx_ct_helpers:start_apps([emqx]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ init_per_suite(Config) ->
|
||||||
code:add_path(filename:join([AppPath, "_build", "default", "lib", "emqx_mini_plugin", "ebin"])),
|
code:add_path(filename:join([AppPath, "_build", "default", "lib", "emqx_mini_plugin", "ebin"])),
|
||||||
|
|
||||||
put(loaded_file, filename:join([DataPath, "loaded_plugins"])),
|
put(loaded_file, filename:join([DataPath, "loaded_plugins"])),
|
||||||
|
emqx_ct_helpers:boot_modules([]),
|
||||||
emqx_ct_helpers:start_apps([], fun set_sepecial_cfg/1),
|
emqx_ct_helpers:start_apps([], fun set_sepecial_cfg/1),
|
||||||
|
|
||||||
Config.
|
Config.
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
-include_lib("common_test/include/ct.hrl").
|
-include_lib("common_test/include/ct.hrl").
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules([router]),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
all() -> emqx_ct:all(?SUITE).
|
all() -> emqx_ct:all(?SUITE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
all() -> [t_start_traces].
|
all() -> [t_start_traces].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
emqx_ct_helpers:boot_modules(all),
|
||||||
emqx_ct_helpers:start_apps([]),
|
emqx_ct_helpers:start_apps([]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue