fix: stop port apps when emqx_machine_terminator shutdown
This commit is contained in:
parent
102f427aac
commit
0738444da9
|
@ -21,6 +21,7 @@
|
||||||
-export([stop_apps/0, ensure_apps_started/0]).
|
-export([stop_apps/0, ensure_apps_started/0]).
|
||||||
-export([sorted_reboot_apps/0]).
|
-export([sorted_reboot_apps/0]).
|
||||||
-export([start_autocluster/0]).
|
-export([start_autocluster/0]).
|
||||||
|
-export([stop_port_apps/0]).
|
||||||
|
|
||||||
-dialyzer({no_match, [basic_reboot_apps/0]}).
|
-dialyzer({no_match, [basic_reboot_apps/0]}).
|
||||||
|
|
||||||
|
@ -61,6 +62,20 @@ stop_apps() ->
|
||||||
_ = emqx_alarm_handler:unload(),
|
_ = emqx_alarm_handler:unload(),
|
||||||
lists:foreach(fun stop_one_app/1, lists:reverse(sorted_reboot_apps())).
|
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) ->
|
stop_one_app(App) ->
|
||||||
?SLOG(debug, #{msg => "stopping_app", app => App}),
|
?SLOG(debug, #{msg => "stopping_app", app => App}),
|
||||||
try
|
try
|
||||||
|
|
|
@ -87,7 +87,8 @@ handle_cast(_Cast, State) ->
|
||||||
|
|
||||||
handle_call(?DO_IT, _From, State) ->
|
handle_call(?DO_IT, _From, State) ->
|
||||||
try
|
try
|
||||||
emqx_machine_boot:stop_apps()
|
emqx_machine_boot:stop_apps(),
|
||||||
|
emqx_machine_boot:stop_port_apps()
|
||||||
catch
|
catch
|
||||||
C:E:St ->
|
C:E:St ->
|
||||||
Apps = [element(1, A) || A <- application:which_applications()],
|
Apps = [element(1, A) || A <- application:which_applications()],
|
||||||
|
|
Loading…
Reference in New Issue