Skip to content

Commit

Permalink
fix(emqx_stomp): fix hot-upgrade stopping listener failed
Browse files Browse the repository at this point in the history
When the upgrade is executed, all envs of plugins are cleared,
which causes the listener of stomp to stop failing.

This is only a temporary modification to ensure that the upgrade
can be executed successfully.

following fixes: #6105
  • Loading branch information
HJianBo committed Nov 10, 2021
1 parent 6b06142 commit fefadbc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/emqx_stomp/src/emqx_stomp.appup.src
Expand Up @@ -2,7 +2,8 @@
{VSN,
[{"4.3.1",[{load_module,emqx_stomp_connection,brutal_purge,soft_purge,[]}]},
{"4.3.0",
[{restart_application,emqx_stomp}]},
[{restart_application,emqx_stomp},
{apply,{emqx_stomp,force_clear_after_app_stoped,[]}}]},
{<<".*">>,[]}],
[{"4.3.1",[{load_module,emqx_stomp_connection,brutal_purge,soft_purge,[]}]},
{"4.3.0",
Expand Down
14 changes: 14 additions & 0 deletions apps/emqx_stomp/src/emqx_stomp.erl
Expand Up @@ -33,6 +33,8 @@
, stop_listener/3
]).

-export([force_clear_after_app_stoped/0]).

-export([init/1]).

-define(APP, ?MODULE).
Expand All @@ -52,6 +54,18 @@ start(_StartType, _StartArgs) ->
stop(_State) ->
stop_listeners().

force_clear_after_app_stoped() ->
lists:foreach(fun({Name = {ProtoName, _}, _}) ->
case is_stomp_listener(ProtoName) of
true -> esockd:close(Name);
_ -> ok
end
end, esockd:listeners()).

is_stomp_listener('stomp:tcp') -> true;
is_stomp_listener('stomp:ssl') -> true;
is_stomp_listener(_) -> false.

%%--------------------------------------------------------------------
%% Supervisor callbacks
%%--------------------------------------------------------------------
Expand Down

0 comments on commit fefadbc

Please sign in to comment.