fix: stop port apps when emqx_machine_terminator shutdown

This commit is contained in:
Zhongwen Deng 2023-03-14 15:39:50 +08:00
parent 102f427aac
commit 0738444da9
2 changed files with 17 additions and 1 deletions

View File

@ -21,6 +21,7 @@
-export([stop_apps/0, ensure_apps_started/0]).
-export([sorted_reboot_apps/0]).
-export([start_autocluster/0]).
-export([stop_port_apps/0]).
-dialyzer({no_match, [basic_reboot_apps/0]}).
@ -61,6 +62,20 @@ stop_apps() ->
_ = emqx_alarm_handler:unload(),
lists:foreach(fun stop_one_app/1, lists:reverse(sorted_reboot_apps())).
%% Those port apps are terminated after the main apps
%% Don't need to stop when reboot.
stop_port_apps() ->
Loaded = application:loaded_applications(),
lists:foreach(
fun(App) ->
case lists:keymember(App, 1, Loaded) of
true -> stop_one_app(App);
false -> ok
end
end,
[os_mon, jq]
).
stop_one_app(App) ->
?SLOG(debug, #{msg => "stopping_app", app => App}),
try

View File

@ -87,7 +87,8 @@ handle_cast(_Cast, State) ->
handle_call(?DO_IT, _From, State) ->
try
emqx_machine_boot:stop_apps()
emqx_machine_boot:stop_apps(),
emqx_machine_boot:stop_port_apps()
catch
C:E:St ->
Apps = [element(1, A) || A <- application:which_applications()],