Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨优化源码部署脚本 #545

Merged
merged 2 commits into from
Aug 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions scripts/base/install_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions scripts/client/check.sh
Original file line number Diff line number Diff line change
@@ -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"
}
2 changes: 2 additions & 0 deletions scripts/config.sh
Original file line number Diff line number Diff line change
@@ -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"}
Expand Down
3 changes: 3 additions & 0 deletions scripts/deploy/tca_local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -182,6 +184,7 @@ function tca_local_main() {
;;
check)
check_tca_local_status
check_tca_client_status
;;
log)
get_tca_local_log
Expand Down