refactor(relup): don't collect relvsn -> appvsn mappings
This commit is contained in:
parent
7698ad7c4b
commit
41afbd2b13
3
build
3
build
|
@ -136,6 +136,9 @@ make_zip() {
|
||||||
local tarball="${relpath}/${tarname}"
|
local tarball="${relpath}/${tarname}"
|
||||||
local target_zip="${pkgpath}/${pkgname}"
|
local target_zip="${pkgpath}/${pkgname}"
|
||||||
tar zxf "${tarball}" -C "${tard}/emqx"
|
tar zxf "${tarball}" -C "${tard}/emqx"
|
||||||
|
if ! [[ $SYSTEM == windows* ]]; then
|
||||||
|
./scripts/inject-relup.escript "${tard}/emqx/releases/${PKG_VSN}/relup"
|
||||||
|
fi
|
||||||
cp_dyn_libs "${tard}/emqx"
|
cp_dyn_libs "${tard}/emqx"
|
||||||
pushd "${tard}" >/dev/null
|
pushd "${tard}" >/dev/null
|
||||||
case "$SYSTEM" in
|
case "$SYSTEM" in
|
||||||
|
|
|
@ -128,34 +128,23 @@ prod_compile_opts() ->
|
||||||
prod_overrides() ->
|
prod_overrides() ->
|
||||||
[{add, [ {erl_opts, [deterministic]}]}].
|
[{add, [ {erl_opts, [deterministic]}]}].
|
||||||
|
|
||||||
relup_deps(Profile, Vsn) ->
|
|
||||||
InjectCmd = "scripts/inject-relup.escript " ++ filename:join(["_build", Profile, "rel", "emqx"]) ++ " " ++ Vsn,
|
|
||||||
{post_hooks,
|
|
||||||
[ {"(linux|darwin|solaris|freebsd|netbsd|openbsd)", relup, InjectCmd}
|
|
||||||
]
|
|
||||||
}.
|
|
||||||
|
|
||||||
profiles() ->
|
profiles() ->
|
||||||
Vsn = get_vsn(),
|
Vsn = get_vsn(),
|
||||||
[ {'emqx', [ {erl_opts, prod_compile_opts()}
|
[ {'emqx', [ {erl_opts, prod_compile_opts()}
|
||||||
, {relx, relx(Vsn, cloud, bin)}
|
, {relx, relx(Vsn, cloud, bin)}
|
||||||
, {overrides, prod_overrides()}
|
, {overrides, prod_overrides()}
|
||||||
, relup_deps('emqx', Vsn)
|
|
||||||
]}
|
]}
|
||||||
, {'emqx-pkg', [ {erl_opts, prod_compile_opts()}
|
, {'emqx-pkg', [ {erl_opts, prod_compile_opts()}
|
||||||
, {relx, relx(Vsn, cloud, pkg)}
|
, {relx, relx(Vsn, cloud, pkg)}
|
||||||
, {overrides, prod_overrides()}
|
, {overrides, prod_overrides()}
|
||||||
, relup_deps('emqx-pkg', Vsn)
|
|
||||||
]}
|
]}
|
||||||
, {'emqx-edge', [ {erl_opts, prod_compile_opts()}
|
, {'emqx-edge', [ {erl_opts, prod_compile_opts()}
|
||||||
, {relx, relx(Vsn, edge, bin)}
|
, {relx, relx(Vsn, edge, bin)}
|
||||||
, {overrides, prod_overrides()}
|
, {overrides, prod_overrides()}
|
||||||
, relup_deps('emqx-edge', Vsn)
|
|
||||||
]}
|
]}
|
||||||
, {'emqx-edge-pkg', [ {erl_opts, prod_compile_opts()}
|
, {'emqx-edge-pkg', [ {erl_opts, prod_compile_opts()}
|
||||||
, {relx, relx(Vsn, edge, pkg)}
|
, {relx, relx(Vsn, edge, pkg)}
|
||||||
, {overrides, prod_overrides()}
|
, {overrides, prod_overrides()}
|
||||||
, relup_deps('emqx-edge-pkg', Vsn)
|
|
||||||
]}
|
]}
|
||||||
, {check, [ {erl_opts, common_compile_opts()}
|
, {check, [ {erl_opts, common_compile_opts()}
|
||||||
]}
|
]}
|
||||||
|
|
|
@ -8,34 +8,27 @@
|
||||||
-define(INFO(FORMAT, ARGS), io:format(user, "[inject-relup] " ++ FORMAT ++ "~n", ARGS)).
|
-define(INFO(FORMAT, ARGS), io:format(user, "[inject-relup] " ++ FORMAT ++ "~n", ARGS)).
|
||||||
|
|
||||||
usage() ->
|
usage() ->
|
||||||
"Usage: " ++ escript:script_name() ++ " <path-to-release-dir> <release-vsn>".
|
"Usage: " ++ escript:script_name() ++ " <path-to-relup-file>".
|
||||||
|
|
||||||
main([RelRootDir, CurrRelVsn]) ->
|
main([RelupFile]) ->
|
||||||
case filelib:is_dir(filename:join([RelRootDir, "releases"])) andalso
|
case filelib:is_regular(RelupFile) of
|
||||||
filelib:is_dir(filename:join([RelRootDir, "lib"])) of
|
|
||||||
true ->
|
true ->
|
||||||
EmqxAppVsns = get_emqx_app_vsns(RelRootDir),
|
ok = inject_relup_file(RelupFile);
|
||||||
ok = inject_relup_file(RelRootDir, CurrRelVsn, EmqxAppVsns);
|
|
||||||
false ->
|
false ->
|
||||||
?ERROR("not a valid root dir of release: ~p, for example: _build/emqx/rel/emqx",
|
?ERROR("not a valid file: ~p", [RelupFile]),
|
||||||
[RelRootDir]),
|
|
||||||
erlang:halt(1)
|
erlang:halt(1)
|
||||||
end;
|
end;
|
||||||
main(_Args) ->
|
main(_Args) ->
|
||||||
?ERROR("~s", [usage()]),
|
?ERROR("~s", [usage()]),
|
||||||
erlang:halt(1).
|
erlang:halt(1).
|
||||||
|
|
||||||
inject_relup_file(RelRootDir, CurrRelVsn, EmqxAppVsns) ->
|
inject_relup_file(File) ->
|
||||||
RelupFile = filename:join([RelRootDir, "releases", CurrRelVsn, "relup"]),
|
|
||||||
inject_file(RelupFile, EmqxAppVsns).
|
|
||||||
|
|
||||||
inject_file(File, EmqxAppVsns) ->
|
|
||||||
case file:script(File) of
|
case file:script(File) of
|
||||||
{ok, {CurrRelVsn, UpVsnRUs, DnVsnRUs}} ->
|
{ok, {CurrRelVsn, UpVsnRUs, DnVsnRUs}} ->
|
||||||
?INFO("injecting instructions to: ~p", [File]),
|
?INFO("injecting instructions to: ~p", [File]),
|
||||||
UpdatedContent = {CurrRelVsn,
|
UpdatedContent = {CurrRelVsn,
|
||||||
inject_relup_instrs(up, EmqxAppVsns, CurrRelVsn, UpVsnRUs),
|
inject_relup_instrs(up, UpVsnRUs),
|
||||||
inject_relup_instrs(down, EmqxAppVsns, CurrRelVsn, DnVsnRUs)},
|
inject_relup_instrs(down, DnVsnRUs)},
|
||||||
file:write_file(File, term_to_text(UpdatedContent));
|
file:write_file(File, term_to_text(UpdatedContent));
|
||||||
{ok, _BadFormat} ->
|
{ok, _BadFormat} ->
|
||||||
?ERROR("bad formatted relup file: ~p", [File]),
|
?ERROR("bad formatted relup file: ~p", [File]),
|
||||||
|
@ -48,101 +41,77 @@ inject_file(File, EmqxAppVsns) ->
|
||||||
error({read_relup_error, Reason})
|
error({read_relup_error, Reason})
|
||||||
end.
|
end.
|
||||||
|
|
||||||
inject_relup_instrs(Type, EmqxAppVsns, CurrRelVsn, RUs) ->
|
inject_relup_instrs(Type, RUs) ->
|
||||||
lists:map(fun
|
lists:map(fun({Vsn, Desc, Instrs}) ->
|
||||||
({Vsn, "(relup-injected) " ++ _ = Desc, Instrs}) -> %% already injected
|
{Vsn, Desc, append_emqx_relup_instrs(Type, Vsn, Instrs)}
|
||||||
{Vsn, Desc, Instrs};
|
|
||||||
({Vsn, Desc, Instrs}) ->
|
|
||||||
{Vsn, "(relup-injected) " ++ Desc,
|
|
||||||
append_emqx_relup_instrs(Type, EmqxAppVsns, CurrRelVsn, Vsn, Instrs)}
|
|
||||||
end, RUs).
|
end, RUs).
|
||||||
|
|
||||||
%% The `{apply, emqx_relup, post_release_upgrade, []}` will be appended to the end of
|
%% The `{apply, emqx_relup, post_release_upgrade, []}` will be appended to the end of
|
||||||
%% the instruction lists.
|
%% the instruction lists.
|
||||||
append_emqx_relup_instrs(up, EmqxAppVsns, CurrRelVsn, FromRelVsn, Instrs0) ->
|
append_emqx_relup_instrs(up, FromRelVsn, Instrs0) ->
|
||||||
{EmqxVsn, true} = maps:get(CurrRelVsn, EmqxAppVsns),
|
|
||||||
Extra = #{}, %% we may need some extended args
|
Extra = #{}, %% we may need some extended args
|
||||||
LoadObjEmqxMods = {load_object_code, {emqx, EmqxVsn, [emqx_relup, emqx_app]}},
|
filter_and_check_instrs(up, Instrs0) ++
|
||||||
LoadCodeEmqxRelup = {load, {emqx_relup, brutal_purge, soft_purge}},
|
[ {load, {emqx_app, brutal_purge, soft_purge}}
|
||||||
LoadCodeEmqxApp = {load, {emqx_app, brutal_purge, soft_purge}},
|
, {load, {emqx_relup, brutal_purge, soft_purge}}
|
||||||
ApplyEmqxRelup = {apply, {emqx_relup, post_release_upgrade, [FromRelVsn, Extra]}},
|
, {apply, {emqx_relup, post_release_upgrade, [FromRelVsn, Extra]}}
|
||||||
Instrs1 = Instrs0 -- [LoadCodeEmqxRelup, LoadCodeEmqxApp],
|
|
||||||
%% we have to put 'load_object_code' before 'point_of_no_return'
|
|
||||||
%% so here we simply put them to the beginning of the instruction list
|
|
||||||
Instrs2 = [ LoadObjEmqxMods
|
|
||||||
| Instrs1],
|
|
||||||
%% the `load` must be put after the 'point_of_no_return'
|
|
||||||
Instrs2 ++
|
|
||||||
[ LoadCodeEmqxRelup
|
|
||||||
, LoadCodeEmqxApp
|
|
||||||
, ApplyEmqxRelup
|
|
||||||
];
|
];
|
||||||
|
|
||||||
append_emqx_relup_instrs(down, EmqxAppVsns, _CurrRelVsn, ToRelVsn, Instrs0) ->
|
append_emqx_relup_instrs(down, ToRelVsn, Instrs0) ->
|
||||||
Extra = #{}, %% we may need some extended args
|
Extra = #{}, %% we may need some extended args
|
||||||
ApplyEmqxRelup = {apply, {emqx_relup, post_release_downgrade, [ToRelVsn, Extra]}},
|
%% NOTE: When downgrading, we apply emqx_relup:post_release_downgrade/2 before reloading
|
||||||
case maps:get(ToRelVsn, EmqxAppVsns) of
|
%% or removing the emqx_relup module.
|
||||||
{EmqxVsn, true} ->
|
Instrs1 = filter_and_check_instrs(down, Instrs0) ++
|
||||||
LoadObjEmqxMods = {load_object_code, {emqx, EmqxVsn, [emqx_relup, emqx_app]}},
|
[ {load, {emqx_app, brutal_purge, soft_purge}}
|
||||||
LoadCodeEmqxRelup = {load, {emqx_relup, brutal_purge, soft_purge}},
|
, {apply, {emqx_relup, post_release_downgrade, [ToRelVsn, Extra]}}
|
||||||
LoadCodeEmqxApp = {load, {emqx_app, brutal_purge, soft_purge}},
|
],
|
||||||
Instrs1 = Instrs0 -- [LoadCodeEmqxRelup, LoadCodeEmqxApp, ApplyEmqxRelup],
|
%% emqx_relup does not exist before release "4.4.2"
|
||||||
Instrs2 = [ LoadObjEmqxMods
|
LoadInsts =
|
||||||
| Instrs1],
|
case ToRelVsn of
|
||||||
%% NOTE: We apply emqx_relup:post_release_downgrade/2 first, and then reload
|
ToRelVsn when ToRelVsn =:= "4.4.1"; ToRelVsn =:= "4.4.0" ->
|
||||||
%% the old vsn code of emqx_relup.
|
[{remove, {emqx_relup, brutal_purge, brutal_purge}}];
|
||||||
Instrs2 ++
|
_ ->
|
||||||
[ LoadCodeEmqxApp
|
[{load, {emqx_relup, brutal_purge, soft_purge}}]
|
||||||
, ApplyEmqxRelup
|
end,
|
||||||
, LoadCodeEmqxRelup
|
Instrs1 ++ LoadInsts.
|
||||||
];
|
|
||||||
{EmqxVsn, false} ->
|
filter_and_check_instrs(Type, Instrs) ->
|
||||||
LoadObjEmqxApp = {load_object_code, {emqx, EmqxVsn, [emqx_app]}},
|
case take_emqx_vsn_and_modules(Instrs) of
|
||||||
LoadCodeEmqxApp = {load, {emqx_app, brutal_purge, soft_purge}},
|
{EmqxAppVsn, EmqxMods, RemainInstrs} when EmqxAppVsn =/= not_found, EmqxMods =/= [] ->
|
||||||
RemoveCodeEmqxRelup = {remove, {emqx_relup, brutal_purge, soft_purge}},
|
assert_mandatory_modules(Type, EmqxMods),
|
||||||
Instrs1 = Instrs0 -- [LoadCodeEmqxApp, RemoveCodeEmqxRelup, ApplyEmqxRelup],
|
[{load_object_code, {emqx, EmqxAppVsn, EmqxMods}} | RemainInstrs];
|
||||||
Instrs2 = [ LoadObjEmqxApp
|
{_, _, _} ->
|
||||||
| Instrs1],
|
?ERROR("cannot found 'load_module' instructions for app emqx", []),
|
||||||
Instrs2 ++
|
error({instruction_not_found, load_object_code})
|
||||||
[ LoadCodeEmqxApp
|
|
||||||
, ApplyEmqxRelup
|
|
||||||
, RemoveCodeEmqxRelup
|
|
||||||
]
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
get_emqx_app_vsns(RelRootDir) ->
|
take_emqx_vsn_and_modules(Instrs) ->
|
||||||
RelFiles = filelib:wildcard(filename:join([RelRootDir, "releases", "*", "emqx.rel"])),
|
lists:foldl(fun
|
||||||
lists:foldl(fun(RelFile, AppVsns) ->
|
({load_object_code, {emqx, AppVsn, Mods}}, {_EmqxAppVsn, EmqxMods, RemainInstrs}) ->
|
||||||
{ok, RelVsn, EmqxVsn} = read_emqx_vsn_from_rel_file(RelFile),
|
{AppVsn, EmqxMods ++ Mods, RemainInstrs};
|
||||||
AppVsns#{RelVsn => {EmqxVsn, has_relup_module(RelRootDir, EmqxVsn)}}
|
({load, {Mod, _, _}}, {EmqxAppVsn, EmqxMods, RemainInstrs})
|
||||||
end, #{}, RelFiles).
|
when Mod =:= emqx_relup; Mod =:= emqx_app ->
|
||||||
|
{EmqxAppVsn, EmqxMods, RemainInstrs};
|
||||||
|
({remove, {emqx_relup, _, _}}, {EmqxAppVsn, EmqxMods, RemainInstrs}) ->
|
||||||
|
{EmqxAppVsn, EmqxMods, RemainInstrs};
|
||||||
|
({apply, {emqx_relup, _, _}}, {EmqxAppVsn, EmqxMods, RemainInstrs}) ->
|
||||||
|
{EmqxAppVsn, EmqxMods, RemainInstrs};
|
||||||
|
(Instr, {EmqxAppVsn, EmqxMods, RemainInstrs}) ->
|
||||||
|
{EmqxAppVsn, EmqxMods, RemainInstrs ++ [Instr]}
|
||||||
|
end, {not_found, [], []}, Instrs).
|
||||||
|
|
||||||
read_emqx_vsn_from_rel_file(RelFile) ->
|
assert_mandatory_modules(up, Mods) ->
|
||||||
case file:script(RelFile) of
|
assert(lists:member(emqx_relup, Mods) andalso lists:member(emqx_app, Mods),
|
||||||
{ok, {release, {_RelName, RelVsn}, _Erts, Apps}} ->
|
"cannot found 'load_module' instructions for emqx_app and emqx_rel: ~p", [Mods]);
|
||||||
case lists:keysearch(emqx, 1, Apps) of
|
|
||||||
{value, {emqx, EmqxVsn}} ->
|
|
||||||
{ok, RelVsn, EmqxVsn};
|
|
||||||
false ->
|
|
||||||
error({emqx_vsn_cannot_found, RelFile})
|
|
||||||
end;
|
|
||||||
{ok, _BadFormat} ->
|
|
||||||
?ERROR("bad formatted .rel file: ~p", [RelFile]);
|
|
||||||
{error, Reason} ->
|
|
||||||
?ERROR("read .rel file ~p failed: ~p", [RelFile, Reason])
|
|
||||||
end.
|
|
||||||
|
|
||||||
has_relup_module(RelRootDir, EmqxVsn) ->
|
assert_mandatory_modules(down, Mods) ->
|
||||||
AppFile = filename:join([RelRootDir, "lib", "emqx-" ++ EmqxVsn, "ebin", "emqx.app"]),
|
assert(lists:member(emqx_app, Mods),
|
||||||
case file:script(AppFile) of
|
"cannot found 'load_module' instructions for emqx_app", []).
|
||||||
{ok, {application, emqx, AppInfo}} ->
|
|
||||||
{value, {_, EmqxVsn}} = lists:keysearch(vsn, 1, AppInfo), %% assert
|
assert(true, _, _) ->
|
||||||
{value, {_, Modules}} = lists:keysearch(modules, 1, AppInfo),
|
ok;
|
||||||
lists:member(emqx_relup, Modules);
|
assert(false, Msg, Args) ->
|
||||||
{error, Reason} ->
|
?ERROR(Msg, Args),
|
||||||
?ERROR("read .app file ~p failed: ~p", [AppFile, Reason]),
|
error(assert_failed).
|
||||||
error({read_app_file_error, AppFile, Reason})
|
|
||||||
end.
|
|
||||||
|
|
||||||
term_to_text(Term) ->
|
term_to_text(Term) ->
|
||||||
io_lib:format("~p.", [Term]).
|
io_lib:format("~p.", [Term]).
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
%% -*- mode: erlang -*-
|
%% -*- mode: erlang -*-
|
||||||
{VSN,
|
{VSN,
|
||||||
[{"4.4.1",
|
[{"4.4.1",
|
||||||
[{load_module,emqx_os_mon,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_app,brutal_purge,soft_purge,[]},
|
||||||
|
{add_module,emqx_relup},
|
||||||
|
{load_module,emqx_os_mon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
||||||
|
@ -10,7 +12,8 @@
|
||||||
{load_module,emqx_ctl,brutal_purge,soft_purge,[]},
|
{load_module,emqx_ctl,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_channel,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_channel,brutal_purge,soft_purge,[]}]},
|
||||||
{"4.4.0",
|
{"4.4.0",
|
||||||
[{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
[{add_module,emqx_relup},
|
||||||
|
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_vm_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_vm_mon,brutal_purge,soft_purge,[]},
|
||||||
|
@ -31,7 +34,9 @@
|
||||||
{load_module,emqx_limiter,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_limiter,brutal_purge,soft_purge,[]}]},
|
||||||
{<<".*">>,[]}],
|
{<<".*">>,[]}],
|
||||||
[{"4.4.1",
|
[{"4.4.1",
|
||||||
[{load_module,emqx_os_mon,brutal_purge,soft_purge,[]},
|
[{load_module,emqx_app,brutal_purge,soft_purge,[]},
|
||||||
|
{delete_module,emqx_relup},
|
||||||
|
{load_module,emqx_os_mon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
||||||
|
@ -40,7 +45,8 @@
|
||||||
{load_module,emqx_ctl,brutal_purge,soft_purge,[]},
|
{load_module,emqx_ctl,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_channel,brutal_purge,soft_purge,[]}]},
|
{load_module,emqx_channel,brutal_purge,soft_purge,[]}]},
|
||||||
{"4.4.0",
|
{"4.4.0",
|
||||||
[{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
[{delete_module,emqx_relup},
|
||||||
|
{load_module,emqx_pmon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
{load_module,emqx_cm,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_sys_mon,brutal_purge,soft_purge,[]},
|
||||||
{load_module,emqx_vm_mon,brutal_purge,soft_purge,[]},
|
{load_module,emqx_vm_mon,brutal_purge,soft_purge,[]},
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2017-2021 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%
|
||||||
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
%% you may not use this file except in compliance with the License.
|
||||||
|
%% You may obtain a copy of the License at
|
||||||
|
%%
|
||||||
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%
|
||||||
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%% See the License for the specific language governing permissions and
|
||||||
|
%% limitations under the License.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
-module(emqx_relup).
|
-module(emqx_relup).
|
||||||
|
|
||||||
|
%% NOTE: DO NOT remove this `-include`.
|
||||||
|
%% We use this to forece this module to upgraded every release.
|
||||||
|
-include("emqx_release.hrl").
|
||||||
|
|
||||||
-export([ post_release_upgrade/2
|
-export([ post_release_upgrade/2
|
||||||
, post_release_downgrade/2
|
, post_release_downgrade/2
|
||||||
]).
|
]).
|
||||||
|
@ -8,13 +28,15 @@
|
||||||
-define(INFO(FORMAT, ARGS), io:format("[emqx_relup] " ++ FORMAT ++ "~n", ARGS)).
|
-define(INFO(FORMAT, ARGS), io:format("[emqx_relup] " ++ FORMAT ++ "~n", ARGS)).
|
||||||
|
|
||||||
%% what to do after upgraded from a old release vsn.
|
%% what to do after upgraded from a old release vsn.
|
||||||
post_release_upgrade(_FromRelVsn, _) ->
|
post_release_upgrade(FromRelVsn, _) ->
|
||||||
?INFO("emqx has been upgraded to ~s", [emqx_app:get_release()]),
|
{_, CurrRelVsn} = ?EMQX_RELEASE,
|
||||||
|
?INFO("emqx has been upgraded to from ~s to ~s!", [FromRelVsn, CurrRelVsn]),
|
||||||
reload_components().
|
reload_components().
|
||||||
|
|
||||||
%% what to do after downgraded to a old release vsn.
|
%% what to do after downgraded to a old release vsn.
|
||||||
post_release_downgrade(_ToRelVsn, _) ->
|
post_release_downgrade(ToRelVsn, _) ->
|
||||||
?INFO("emqx has been downgrade to ~s", [emqx_app:get_release()]),
|
{_, CurrRelVsn} = ?EMQX_RELEASE,
|
||||||
|
?INFO("emqx has been downgraded to from ~s to ~s!", [CurrRelVsn, ToRelVsn]),
|
||||||
reload_components().
|
reload_components().
|
||||||
|
|
||||||
-ifdef(EMQX_ENTERPRISE).
|
-ifdef(EMQX_ENTERPRISE).
|
||||||
|
|
Loading…
Reference in New Issue