From cbeb4e52e5b4c370d5e6c5f6c6a970cb296a3954 Mon Sep 17 00:00:00 2001 From: Lingghh Date: Wed, 17 Aug 2022 19:10:07 +0800 Subject: [PATCH 1/2] =?UTF-8?q?:art:=E6=BA=90=E7=A0=81=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E5=AE=A2=E6=88=B7=E7=AB=AF?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/client/check.sh | 36 ++++++++++++++++++++++++++++++++++++ scripts/deploy/tca_local.sh | 3 +++ 2 files changed, 39 insertions(+) create mode 100644 scripts/client/check.sh diff --git a/scripts/client/check.sh b/scripts/client/check.sh new file mode 100644 index 000000000..60d2a4a8f --- /dev/null +++ b/scripts/client/check.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +CURRENT_SCRIPT_PATH=$(cd "$(dirname "${BASH_SOURCE[0]}")";pwd) +TCA_SCRIPT_ROOT=${TCA_SCRIPT_ROOT:-"$(cd $(dirname $CURRENT_SCRIPT_PATH); pwd)"} +TCA_PROJECT_PATH=${TCA_PROJECT_PATH:-"$(cd "$(dirname $TCA_SCRIPT_ROOT)"; pwd)"} + + +source $TCA_SCRIPT_ROOT/utils.sh + +function check_result() { + name=$1 + ret=$2 + if [ "$ret" = "true" ]; then + LOG_INFO "$name start: OK." + return 0 + else + LOG_ERROR "$name start: Failed." + return 1 + fi +} + +function check_client_running() { + client_result=$( check_target_process_exist "codepuppy") + if [ "$client_result" = "true" ]; then + return 0 + else + return 1 + fi +} + +function check_tca_client_status() { + client_result="" + LOG_INFO "Check client start status..." + check_client_running + check_result "tca_client" "$client_result" +} diff --git a/scripts/deploy/tca_local.sh b/scripts/deploy/tca_local.sh index a0d975768..4d242af1a 100755 --- a/scripts/deploy/tca_local.sh +++ b/scripts/deploy/tca_local.sh @@ -16,6 +16,7 @@ source $TCA_SCRIPT_ROOT/server/start.sh source $TCA_SCRIPT_ROOT/server/stop.sh source $TCA_SCRIPT_ROOT/server/healthcheck.sh source $TCA_SCRIPT_ROOT/client/init.sh +source $TCA_SCRIPT_ROOT/client/check.sh source $TCA_SCRIPT_ROOT/client/start.sh source $TCA_SCRIPT_ROOT/client/stop.sh @@ -170,6 +171,7 @@ function tca_local_main() { tca_local_start sleep 2 check_tca_local_status + check_tca_client_status ;; install) tca_local_install $service @@ -182,6 +184,7 @@ function tca_local_main() { ;; check) check_tca_local_status + check_tca_client_status ;; log) get_tca_local_log From c81317871a63c8c3ea0e581065f09f0802597ebf Mon Sep 17 00:00:00 2001 From: Lingghh Date: Wed, 17 Aug 2022 19:10:56 +0800 Subject: [PATCH 2/2] =?UTF-8?q?:art:=E6=BA=90=E7=A0=81=E9=83=A8=E7=BD=B2?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E6=94=AF=E6=8C=81=E9=85=8D=E7=BD=AE=E5=A4=96?= =?UTF-8?q?=E9=83=A8mysql=E5=92=8Credis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/base/install_db.sh | 8 ++++++++ scripts/config.sh | 2 ++ 2 files changed, 10 insertions(+) diff --git a/scripts/base/install_db.sh b/scripts/base/install_db.sh index c08284e81..7bca114da 100644 --- a/scripts/base/install_db.sh +++ b/scripts/base/install_db.sh @@ -402,6 +402,10 @@ function quiet_install_mariadb() { # 交互式安装Redis # #################################### function interactive_install_redis() { + if [ "$USE_EXTERNAL_REDIS" == "true" ]; then + LOG_INFO "Use external redis, host: $REDIS_HOST, port: $REDIS_PORT" + return 0 + fi ret=$( check_redis ) if [ "$ret" == "true" ]; then return 0 @@ -448,6 +452,10 @@ function interactive_install_mariadb() { esac fi + if [ "$USE_EXTERNAL_MYSQL" == "true" ]; then + LOG_INFO "Use external mysql, host: $MYSQL_HOST, port: $MYSQL_PORT" + return 0 + fi ret=$( check_mysqld ) if [ "$ret" == "true" ]; then return 0 diff --git a/scripts/config.sh b/scripts/config.sh index 5f6eeb4e6..53550baf3 100644 --- a/scripts/config.sh +++ b/scripts/config.sh @@ -1,12 +1,14 @@ #!/bin/bash # -*-*-*- 需要关注的配置内容 -*-*-*- # 数据库配置,默认MySQL端口号为3306 +export USE_EXTERNAL_MYSQL=${USE_EXTERNAL_MYSQL:-false} export MYSQL_HOST=${MYSQL_HOST:-127.0.0.1} export MYSQL_PORT=${MYSQL_PORT:-3306} export MYSQL_USER=${MYSQL_USER:-tca} export MYSQL_PASSWORD=${MYSQL_PASSWORD:-"TCA!@#2021"} # Redis配置,默认Redis端口号为6379 +export USE_EXTERNAL_REDIS=${USE_EXTERNAL_REDIS:-false} export REDIS_HOST=${REDIS_HOST:-127.0.0.1} export REDIS_PORT=${REDIS_PORT:-6379} export REDIS_PASSWD=${REDIS_PASSWD:-"tca2022"}