From 5fca0a16f957d009d1d60f02c19f62f618653087 Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Tue, 28 May 2024 16:56:56 +0800 Subject: [PATCH] feat: rename emqx_relup to emqx_post_upgrade --- apps/emqx/src/emqx_post_upgrade.erl | 38 +++++++++++++++++++ apps/emqx/src/emqx_relup.erl | 42 --------------------- relup/examples/5.6.1-to-5.6.1+patch.A.relup | 5 +-- 3 files changed, 39 insertions(+), 46 deletions(-) create mode 100644 apps/emqx/src/emqx_post_upgrade.erl delete mode 100644 apps/emqx/src/emqx_relup.erl diff --git a/apps/emqx/src/emqx_post_upgrade.erl b/apps/emqx/src/emqx_post_upgrade.erl new file mode 100644 index 000000000..5cbe3877c --- /dev/null +++ b/apps/emqx/src/emqx_post_upgrade.erl @@ -0,0 +1,38 @@ +%%-------------------------------------------------------------------- +%% Copyright (c) 2017-2024 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_post_upgrade). + +%% PR#12765 +-export([ + pr12765_update_stats_timer/1, + pr12765_revert_stats_timer/1 +]). + +-include("logger.hrl"). + +%%------------------------------------------------------------------------------ +%% Hot Upgrade Callback Functions. +%%------------------------------------------------------------------------------ +pr12765_update_stats_timer(_FromVsn) -> + emqx_stats:update_interval(broker_stats, fun emqx_broker_helper:stats_fun/0). + +pr12765_revert_stats_timer(_ToVsn) -> + emqx_stats:update_interval(broker_stats, fun emqx_broker:stats_fun/0). + +%%------------------------------------------------------------------------------ +%% Helper functions +%%------------------------------------------------------------------------------ diff --git a/apps/emqx/src/emqx_relup.erl b/apps/emqx/src/emqx_relup.erl deleted file mode 100644 index bf9157b96..000000000 --- a/apps/emqx/src/emqx_relup.erl +++ /dev/null @@ -1,42 +0,0 @@ -%%-------------------------------------------------------------------- -%% Copyright (c) 2017-2024 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). - -%% NOTE: DO NOT remove this `-include`. -%% We use this to force this module to be upgraded every release. --include("emqx_release.hrl"). - --export([ - post_release_upgrade/2, - post_release_downgrade/2 -]). - --define(INFO(FORMAT), io:format("[emqx_relup] " ++ FORMAT ++ "~n")). --define(INFO(FORMAT, ARGS), io:format("[emqx_relup] " ++ FORMAT ++ "~n", ARGS)). - -%% What to do after upgraded from an old release vsn. -post_release_upgrade(FromRelVsn, _) -> - ?INFO("emqx has been upgraded from ~s to ~s!", [FromRelVsn, emqx_release:version()]), - reload_components(). - -%% What to do after downgraded to an old release vsn. -post_release_downgrade(ToRelVsn, _) -> - ?INFO("emqx has been downgraded from ~s to ~s!", [emqx_release:version(), ToRelVsn]), - reload_components(). - -reload_components() -> - ok. diff --git a/relup/examples/5.6.1-to-5.6.1+patch.A.relup b/relup/examples/5.6.1-to-5.6.1+patch.A.relup index db2d2c813..3f0d7676e 100644 --- a/relup/examples/5.6.1-to-5.6.1+patch.A.relup +++ b/relup/examples/5.6.1-to-5.6.1+patch.A.relup @@ -34,9 +34,6 @@ , {update, emqx_ds_replication_layer_egress, {advanced, #{}}} ], post_upgrade_callbacks => - [ {pr12781_init_db_metrics, pr12781_termiate_db_metrics} - , {pr12781_create_persist_msg_pterm, pr12781_erase_persist_msg_pterm} - , {pr12781_trans_tables, pr12781_revert_tables} - , {pr12765_update_stats_timer, pr12765_revert_stats_timer} + [ {pr12765_update_stats_timer, pr12765_revert_stats_timer} ] }.