From f392645de65ea98e5cb0eacd7f2779d169cee725 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Fri, 22 Sep 2023 22:11:44 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96=E6=95=B0=E6=8D=AE=E5=BA=93=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/0_prepare.sh | 2 +- scripts/utils.sh | 40 ++++++++++++++++++---------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/scripts/0_prepare.sh b/scripts/0_prepare.sh index ae9c5e56..54dc1798 100644 --- a/scripts/0_prepare.sh +++ b/scripts/0_prepare.sh @@ -58,7 +58,7 @@ function prepare_image_files() { fi images=$(get_images) - + for image in ${images}; do echo "[${image}]" pull_image "$image" diff --git a/scripts/utils.sh b/scripts/utils.sh index 2c91be33..774cb658 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -543,7 +543,9 @@ function get_db_migrate_compose_cmd() { function create_db_ops_env() { cmd=$(get_db_migrate_compose_cmd) - ${cmd} up -d + ${cmd} up -d || { + exit 1 + } } function down_db_ops_env() { @@ -552,31 +554,25 @@ function down_db_ops_env() { } function perform_db_migrations() { - if ! create_db_ops_env; then - mysql_host=$(get_config DB_HOST) - redis_host=$(get_config REDIS_HOST) - if [[ "${mysql_host}" == "mysql" ]]; then - while [[ "$(docker inspect -f "{{.State.Health.Status}}" jms_mysql)" != "healthy" ]]; do - sleep 5s - done - fi - if [[ "${redis_host}" == "redis" ]]; then - while [[ "$(docker inspect -f "{{.State.Health.Status}}" jms_redis)" != "healthy" ]]; do - sleep 5s - done - fi - create_db_ops_env - sleep 5s - fi + mysql_host=$(get_config DB_HOST) + redis_host=$(get_config REDIS_HOST) - docker exec -i jms_core bash -c './jms upgrade_db' - ret=$? + create_db_ops_env + if [[ "${mysql_host}" == "mysql" ]]; then + while [[ "$(docker inspect -f "{{.State.Health.Status}}" jms_mysql)" != "healthy" ]]; do + sleep 5s + done + fi + if [[ "${redis_host}" == "redis" ]]; then + while [[ "$(docker inspect -f "{{.State.Health.Status}}" jms_redis)" != "healthy" ]]; do + sleep 5s + done + fi - down_db_ops_env - if [[ "$ret" != "0" ]]; then + docker exec -i jms_core bash -c './jms upgrade_db' || { log_error "$(gettext 'Failed to change the table structure')!" exit 1 - fi + } } function set_current_version() {