Просмотр исходного кода

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

fix: stop port apps when emqx_machine_terminator shutdown
zhongwencool 2 лет назад
Родитель
Сommit
4f1da5e9fa

+ 15 - 0
apps/emqx_machine/src/emqx_machine_boot.erl

@@ -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

+ 2 - 1
apps/emqx_machine/src/emqx_machine_terminator.erl

@@ -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()],

+ 1 - 0
changes/ce/fix-10132.en.md

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

+ 1 - 0
changes/ce/fix-10132.zh.md

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