|
@@ -39,6 +39,9 @@
|
|
|
handle_info/2
|
|
handle_info/2
|
|
|
]).
|
|
]).
|
|
|
|
|
|
|
|
|
|
+%% Internal exports (for `emqx_machine_terminator' only)
|
|
|
|
|
+-export([do_stop_apps/0]).
|
|
|
|
|
+
|
|
|
%%------------------------------------------------------------------------------
|
|
%%------------------------------------------------------------------------------
|
|
|
%% Type declarations
|
|
%% Type declarations
|
|
|
%%------------------------------------------------------------------------------
|
|
%%------------------------------------------------------------------------------
|
|
@@ -77,7 +80,7 @@ handle_call(#start_apps{}, _From, State) ->
|
|
|
handle_start_apps(),
|
|
handle_start_apps(),
|
|
|
{reply, ok, State};
|
|
{reply, ok, State};
|
|
|
handle_call(#stop_apps{}, _From, State) ->
|
|
handle_call(#stop_apps{}, _From, State) ->
|
|
|
- handle_stop_apps(),
|
|
|
|
|
|
|
+ do_stop_apps(),
|
|
|
{reply, ok, State};
|
|
{reply, ok, State};
|
|
|
handle_call(_Call, _From, State) ->
|
|
handle_call(_Call, _From, State) ->
|
|
|
{reply, ignored, State}.
|
|
{reply, ignored, State}.
|
|
@@ -89,21 +92,29 @@ handle_info(_Info, State) ->
|
|
|
{noreply, State}.
|
|
{noreply, State}.
|
|
|
|
|
|
|
|
%%------------------------------------------------------------------------------
|
|
%%------------------------------------------------------------------------------
|
|
|
-%% Internal fns
|
|
|
|
|
|
|
+%% Internal exports
|
|
|
%%------------------------------------------------------------------------------
|
|
%%------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-handle_start_apps() ->
|
|
|
|
|
- ?SLOG(notice, #{msg => "(re)starting_emqx_apps"}),
|
|
|
|
|
- lists:foreach(fun start_one_app/1, emqx_machine_boot:sorted_reboot_apps()),
|
|
|
|
|
- ?tp(emqx_machine_boot_apps_started, #{}).
|
|
|
|
|
-
|
|
|
|
|
-handle_stop_apps() ->
|
|
|
|
|
|
|
+%% Callers who wish to stop applications should not call this directly, and instead use
|
|
|
|
|
+%% `stop_apps/0`. The only exception is `emqx_machine_terminator': it should call this
|
|
|
|
|
+%% block directly in its try-catch block, without the possibility of crashing this
|
|
|
|
|
+%% process.
|
|
|
|
|
+do_stop_apps() ->
|
|
|
?SLOG(notice, #{msg => "stopping_emqx_apps"}),
|
|
?SLOG(notice, #{msg => "stopping_emqx_apps"}),
|
|
|
_ = emqx_alarm_handler:unload(),
|
|
_ = emqx_alarm_handler:unload(),
|
|
|
ok = emqx_conf_app:unset_config_loaded(),
|
|
ok = emqx_conf_app:unset_config_loaded(),
|
|
|
ok = emqx_plugins:ensure_stopped(),
|
|
ok = emqx_plugins:ensure_stopped(),
|
|
|
lists:foreach(fun stop_one_app/1, lists:reverse(emqx_machine_boot:sorted_reboot_apps())).
|
|
lists:foreach(fun stop_one_app/1, lists:reverse(emqx_machine_boot:sorted_reboot_apps())).
|
|
|
|
|
|
|
|
|
|
+%%------------------------------------------------------------------------------
|
|
|
|
|
+%% Internal fns
|
|
|
|
|
+%%------------------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+handle_start_apps() ->
|
|
|
|
|
+ ?SLOG(notice, #{msg => "(re)starting_emqx_apps"}),
|
|
|
|
|
+ lists:foreach(fun start_one_app/1, emqx_machine_boot: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}),
|
|
|
case application:ensure_all_started(App, emqx_machine_boot:restart_type(App)) of
|
|
case application:ensure_all_started(App, emqx_machine_boot:restart_type(App)) of
|