fix(relup): add module emqx_relup

This commit is contained in:
Shawn 2022-02-27 10:23:14 +08:00
parent 2365d1e983
commit 17440b2b53
2 changed files with 19 additions and 1 deletions

View File

@ -49,13 +49,14 @@ inject_relup_instrs(Type, CurrRelVsn, RUs) ->
%% the instruction lists. %% the instruction lists.
append_emqx_relup_instrs(Type, CurrRelVsn, Vsn, Instrs) -> append_emqx_relup_instrs(Type, CurrRelVsn, Vsn, Instrs) ->
CallbackFun = relup_callback_func(Type), CallbackFun = relup_callback_func(Type),
Extra = #{}, %% we may need some extended args
case lists:reverse(Instrs) of case lists:reverse(Instrs) of
[{apply, {emqx_relup, CallbackFun, _}} | _] -> [{apply, {emqx_relup, CallbackFun, _}} | _] ->
Instrs; Instrs;
RInstrs -> RInstrs ->
lists:reverse([ {load_object_code, {emqx, CurrRelVsn, [emqx_relup]}} lists:reverse([ {load_object_code, {emqx, CurrRelVsn, [emqx_relup]}}
, {load, {emqx_relup, brutal_purge, soft_purge}} , {load, {emqx_relup, brutal_purge, soft_purge}}
, {apply, {emqx_relup, CallbackFun, [CurrRelVsn, Vsn]}} , {apply, {emqx_relup, CallbackFun, [CurrRelVsn, Vsn, Extra]}}
| RInstrs]) | RInstrs])
end. end.

17
src/emqx_relup.erl Normal file
View File

@ -0,0 +1,17 @@
-module(emqx_relup).
-export([ post_release_upgrade/3
, post_release_downgrade/3
]).
post_release_upgrade(_CurrRelVsn, _FromVsn, _) ->
reload_components().
post_release_downgrade(_CurrRelVsn, _ToVsn, _) ->
reload_components().
reload_components() ->
io:format("reloading resource providers ..."),
emqx_rule_engine:load_providers(),
io:format("loading plugins ..."),
emqx_plugins:load().