Merge pull request #10132 from zhongwencool/systemd-stop-crash-log

fix: stop port apps when emqx_machine_terminator shutdown
This commit is contained in:
zhongwencool 2023-03-14 17:40:26 +08:00 committed by GitHub
commit 4f1da5e9fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 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()],

View File

@ -0,0 +1 @@
Fix `systemctl stop emqx` command not stopping jq, os_mon application properly, generating some error logs.

View File

@ -0,0 +1 @@
修复`systemctl stop emqx` 命令没有正常停止 jq, os_mon 组件,产生一些错误日志。