Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stop port apps when emqx_machine_terminator shutdown #10132

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions apps/emqx_machine/src/emqx_machine_boot.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]}).

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion apps/emqx_machine/src/emqx_machine_terminator.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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()],
Expand Down
1 change: 1 addition & 0 deletions changes/ce/fix-10132.en.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix `systemctl stop emqx` command not stopping jq, os_mon application properly, generating some error logs.
1 change: 1 addition & 0 deletions changes/ce/fix-10132.zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
修复`systemctl stop emqx` 命令没有正常停止 jq, os_mon 组件,产生一些错误日志。