From e6110b0e9ebf7817418ce1e913432a16ecc4ac8f Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Tue, 27 Jul 2021 16:03:55 +0200 Subject: [PATCH] fix(emqx_app): stop listeners in application prep_stop callback Application:stop is call after the root supervisor is stopped, in our case, prior to this fix, emqx_sup is stopped before the listeners (hence the emqx_connection processes). This causes shutdown to emit a lot of error logs e.g. emqx_broker pool is down, but emqx_connection process is still trying to call the pool --- apps/emqx/src/emqx_app.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/emqx/src/emqx_app.erl b/apps/emqx/src/emqx_app.erl index a3978ad90..3a2e2b123 100644 --- a/apps/emqx/src/emqx_app.erl +++ b/apps/emqx/src/emqx_app.erl @@ -19,6 +19,7 @@ -behaviour(application). -export([ start/2 + , prep_stop/1 , stop/1 , get_description/0 , get_release/0 @@ -63,12 +64,13 @@ start(_Type, _Args) -> print_vsn(), {ok, Sup}. --spec(stop(State :: term()) -> term()). -stop(_State) -> +prep_stop(_State) -> ok = emqx_alarm_handler:unload(), emqx_boot:is_enabled(listeners) andalso emqx_listeners:stop(). +stop(_State) -> ok. + set_backtrace_depth() -> Depth = emqx_config:get([node, backtrace_depth]), _ = erlang:system_flag(backtrace_depth, Depth),