Commit 1592da42 authored by daidekun's avatar daidekun
parents 1ef69605 36309af8
......@@ -114,6 +114,12 @@ elif [[ $database_name = 'merchant' ]]; then
# 用户中心
sys_table_list='authority product_nature role role_authority role_supplier user'
port='3314'
elif [[ $database_name = 'notify' ]]; then
# 白条直投
sys_table_list='merchant merchant_config'
source_db_host='192.168.4.6'
port='7306'
echo "---------------------------"
fi
echo "port is $port"
......
......@@ -19,9 +19,9 @@ echo "delete_business_data:"$delete_business_data
if [ "$delete_business_data" = "true" ];then
echo "DROP DATABASE ${database_name};"
echo "DROP DATABASE ${database_name};" | mysql -h $mysql_host -uqa -pqatest
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;" | mysql -h $mysql_host -uqa -pqatest
fi
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;"
echo "CREATE DATABASE IF NOT EXISTS \`${database_name}\` DEFAULT CHARSET utf8 COLLATE utf8_general_ci;" | mysql -h $mysql_host -uqa -pqatest
echo `pwd`
......
......@@ -10,13 +10,12 @@
source ~/.bash_profile
source ~/.profile
if [ $# -ne 10 ]; then
if [ $# -ne 9 ]; then
echo "---------------"
echo "source_db_infos:source_db_host: $1, source_db_user: $2"
echo "target_db_infos:target_db_host: $4, target_db_user: $5"
echo "sync_db_name: $7, re_replace_ip: $8"
echo "delete_business_data: $9"
echo "run_sql_file : $10"
echo "---参数不正确---"
echo "Usage:sh db_schema_sync.sh source_db_host source_db_user source_db_pwd target_db_host target_db_user target_db_pwd sync_db_name"
echo "---------------"
......@@ -35,7 +34,6 @@ target_db_pwd=$6
sync_db_name=$7
re_replace_ip=$8
delete_business_data=$9
run_sql_file=$10
work_dir=/home/qa-deploy-utils/db-utils
sync_config_folder=~/db_sync_configs
......@@ -99,7 +97,8 @@ function db_schema_sync()
function run_sql_file()
{
echo "run sql files on ${target_db_host}"
sync_db_name=$1
echo "run sql files on ${target_db_host}'s $sync_db_name"
sh $work_dir/db_execute_sql.sh $target_db_host $sync_db_name
}
......@@ -110,13 +109,12 @@ then
for db_name in $database_list
do
echo "----------------------------------------------------"
echo "--- start sync $db_name---"
echo "--- start sync $db_name ---"
db_schema_sync $db_name
echo "--- end sync $db_name---"
run_sql_file $db_name
echo "--- end sync $db_name ---"
echo "----------------------------------------------------"
done
echo $run_sql_file
run_sql_file
else
db_schema_sync $sync_db_name
......
......@@ -8,30 +8,33 @@ Constant_file=${project_path}/app/src/main/java/com/financial/quantgroup/constan
BuildApk_path=${project_path}/build/archives
downloadApk_path=/home/quant_group/jenkins/download_apk
SourceMarkes_flavors=/home/qa-deploy-utils/qa_shell_script/app/markets.txt
branch_name=$1
#${GIT_BRANCH} ${PRODUCT_FLAVORS} ${BUILD_TIME} ${APP_SERVER} ${APP_TYPE} ${APP_VERSION} ${NEED_UPLOAD}
git_branch=$1
product_flavors=$2
build_time=$3
test_server=$4
apk_name=$5
need_upload=$6
apk_type=$5
apk_version=$6
need_upload=$7
cd ${project_path}
function get_code()
{
git checkout ./
git fetch -p
if [ -z ${branch_name} ]; then
if [ -z ${git_branch} ]; then
echo "分支为空,已切换默认分支master"
git pull
else
echo "checkout specified branch ${branch_name}"
git checkout -f ${branch_name}
echo "checkout specified branch ${git_branch}"
git checkout -f ${git_branch}
if [ $? = 0 ]; then
echo "成功切换分支${branch_name}"
echo "成功切换分支${git_branch}"
git pull
else
echo "切换分支${branch_name}失败,请联系管理员查看".
echo "切换分支${git_branch}失败,请联系管理员查看".
exit -1
fi
fi
......@@ -81,15 +84,29 @@ function build_android()
ApkFile=`find ${BuildApk_path} -name "*${product_flavors}*.apk"`
echo "apk名称是:${ApkFile}"
echo "当前路径 `pwd`"
#mv ${ApkFile} ${StroeApk_path}/${branch_name}_${product_flavors}.apk
mv ${ApkFile} ${branch_name}_${product_flavors}_${build_time}.apk
cp -R ${branch_name}_${product_flavors}_${build_time}.apk ${downloadApk_path}/${apk_name}.apk
#mv ${ApkFile} ${StroeApk_path}/${git_branch}_${product_flavors}.apk
mv ${ApkFile} ${git_branch}_${product_flavors}_${build_time}.apk
cp -R ${git_branch}_${product_flavors}_${build_time}.apk ${downloadApk_path}/${apk_type}_${apk_version}.apk
else
echo "构建失败,请联系管理员查看".
exit -1
fi
}
function upload_toLocalAppStore()
{
echo "apk正在本地appstore,请等待......"
#cd ${StroeApk_path}
echo "当前上传apk包的路径是 `pwd`"
echo "curl -F \"file=@${git_branch}_${product_flavors}_${build_time}.apk\" -F \"type=${apk_type}\" -F \"version=${apk_version}\" http://192.168.4.241:9000/android/upload"
curl -F "file=@${git_branch}_${product_flavors}_${build_time}.apk" -F "type=${apk_type}" -F "version=${apk_version}" http://192.168.4.241:9000/android/upload
if [ $? != 0 ]; then
echo "上传失败,请联系管理员查看"
fi
}
function upload_apk()
{
......@@ -97,8 +114,8 @@ function upload_apk()
echo "apk正在上传到蒲公英,请等待......"
#cd ${StroeApk_path}
echo "当前上传apk包的路径是 `pwd`"
#curl -F "file=@${branch_name}_${product_flavors}_${build_time}.apk" -F "uKey=13d17385c02ea9ea994d0c985d87ff32" -F "_api_key=5b09af98d5a8ff43f2f39935fa6bfbc1" https://qiniu-storage.pgyer.com/apiv1/app/upload
curl -F "file=@${branch_name}_${product_flavors}_${build_time}.apk" -F "uKey=41968e9da5a634b7b33dc8ff41e31c4e" -F "_api_key=8c303b6f70e8abbda50d1503568f1864" https://qiniu-storage.pgyer.com/apiv1/app/upload
#curl -F "file=@${git_branch}_${product_flavors}_${build_time}.apk" -F "uKey=13d17385c02ea9ea994d0c985d87ff32" -F "_api_key=5b09af98d5a8ff43f2f39935fa6bfbc1" https://qiniu-storage.pgyer.com/apiv1/app/upload
curl -F "file=@${git_branch}_${product_flavors}_${build_time}.apk" -F "uKey=41968e9da5a634b7b33dc8ff41e31c4e" -F "_api_key=8c303b6f70e8abbda50d1503568f1864" https://qiniu-storage.pgyer.com/apiv1/app/upload
if [ $? != 0 ]; then
echo "上传失败,请联系管理员查看"
fi
......@@ -111,5 +128,7 @@ replace_config
build_android
upload_toLocalAppStore
upload_apk
......@@ -25,6 +25,16 @@ do
done
echo "修改完毕"
echo "准备修改pom文件中的消息中心Notify-SDK测试版本"
nums=(`awk '/quantgroup-notify-sdk/ {print NR}' $project_path/$project/pom.xml`)
for num in ${nums[@]}
do
lin=$[ $num+1 ]
echo "第$lin行 pom文件修改成<version>1.0-SNAPSHOT</version>"
sed -i "${lin}s/version.*-S.*<\/version>/version>1.0-SNAPSHOT<\/version>/" $project_path/$project/pom.xml
done
echo "修改完毕"
echo "$build_command"
$build_command
......
#!/bin/bash
echo "=========================="
echo "==== check service ====="
echo "=========================="
servicetatus="/tmp/servicetatus.sh"
function check(){
_type=$1
_name=$2
_port=$3
_desc=$4
_bleo=$5
_targ=$6
#echo "$result" "$key"
#verify "$result" "$key"
#isstart=$?
_name_c=''
_status=''
_desc_c=''
#echo $_name "curl -s ${host}:${_port}"
result=`curl -s ${host}:${_port}`
if [[ $? == 0 ]]
then
_status='\033[32m start \033[0m'
else
_status='\033[31m stop \033[0m'
fi
if [[ ${#_name} -lt 8 ]]
then
_name_c="${_name}\t\t\t"
fi
if [[ ${#_name} -ge 8 && ${#_name} -lt 16 ]]
then
_name_c="${_name}\t\t"
fi
if [[ ${#_name} -ge 16 ]]
then
_name_c="${_name}\t"
fi
if [[ $_bleo =~ "${_targ}" ]]
then
_desc_c="\033[32m ${_desc} \033[0m"
else
_desc_c=" ${_desc} "
fi
echo "echo -e '${_status}\t|\t${_type}\t|\t${_name_c}\t${_desc_c}' " >>$servicetatus
echo "echo '----------------------------------------------------------------------------------------------'" >>$servicetatus
}
function info(){
process=`ps -ef |grep $1|grep -v grep |wc -l`
if [ $process -eq 0 ];then
_status='\033[31m stop \033[0m'
else
_status='\033[32m start \033[0m'
fi
echo "echo -e '${_status}\t\t\t|\t$1' " >>$servicetatus
}
rm -rf $servicetatus
echo "#!/bin/bash" >>$servicetatus
echo "echo '----------------------------------------------------------------------------------------------'" >>$servicetatus
host="127.0.0.1"
projectStr=`node /home/qa-deploy-utils/qa_shell_script/check/project_item.js`
for line in ${projectStr[@]}; do
#echo "check ${line//|@|/ } $1"
check ${line//|@|/ } $1
done
info "mysql"
info "zookeeper"
info "redis"
chmod 755 $servicetatus
sh $servicetatus
This diff is collapsed.
var item = require("/home/qa-deploy-utils/qa_shell_script/config_server/get_project_config.js");
var p="";
function show(objects){
for(var i = 0;i < objects.length; i++) {
p+=objects[i].type +"|@|" + objects[i].name + "|@|"+ objects[i].port +"|@|" + objects[i].desc.replace(/\s/g,"-") +"|@||" +" ";
}
}
show(item.java);
show(item.ui);
show(item.node);
show(item.python);
console.log(p);
\ No newline at end of file
......@@ -87,7 +87,7 @@ new pClass().init(false, "java", "7014", "", "du-jiang-yan", false, "QG", "du_ji
new pClass().init(false, "java", "8051", "", "msg", false, "micro-service", "msg.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "新版消息中心", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7052", "", "xyqb-btzt", true, "qg-op-backend", "xyqb-btzt.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投外部", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7053", "", "xyqb-btzt-internal", true, "qg-op-backend", "xyqb-btzt-internal.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "白条直投内部", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7060", "", "xyqb-backend", true, "qg-op-backend", "xyqb-backend.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "运营系统服务", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7060", "", "baitiao-op-backend", true, "baitiao", "baitiao-op-backend.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "运营系统服务", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "./xyqb-backend/target");
new pClass().init(true, "java", "7062", "", "xyqb-user2-query", true, "head_group", "xyqb_user_query.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "用户系统查询服务", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7063", "", "traffic-webapp", true, "qg-op-backend", "traffic.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "流量分发系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(false, "java", "7017", "", "silk-road-eureka", true, "baitiao", "silk-road-eureka.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "Eureka 服务注册发现微服务", "魏巍", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
......@@ -101,7 +101,9 @@ new pClass().init(true, "java", "7069", "", "notify", true, "fund_pay", "notify.
new pClass().init(true, "java", "7071", "", "mall-settlement", true, "baitiao", "mall-settlement.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "商户结算系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(true, "java", "7072", "", "data-taurus",true, "data-riskcontrol", "data-taurus.log", "application.properties", " /dev/null 2>&1 &", null, 2, "质保金-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(true, "java", "7074", "", "account-center",false, "QG", "account_center.log", "application.properties", " /dev/null 2>&1 &", null, 2, "账户中心-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(true, "java", "7079", "", "user_credit",false, "QG", "user_credit.log", "application.properties", " /dev/null 2>&1 &", null, 2, "用户升级-server", "","mvn clean package -Ptest -Dmaven.test.skip=true","");
new pClass().init(true, "java", "7076", "", "urge_dispatcher", true, "data-riskcontrol", "dispatcher.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "催收系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
new pClass().init(true, "java", "7081", "", "wechat-config", true, "fund_pay", "wechat-config.log", "application.properties", "--worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &", null, 2, "微信消息推送系统", "", "mvn clean package -Ptest -Dmaven.test.skip=true", "");
// ui----
new pClass().init(true, "ui", "7032", "", "op-ui", false, "QG", null, "src/js/env.config.js", "npm run build", "node7", 1, "运营系统-ui", "", "", "");
......@@ -132,7 +134,7 @@ new pClass().init(true, "ui", "7070", "", "customer-op-ui", true, "ui", null, "s
new pClass().init(true, "ui", "7075", "", "business-op-ui", true, "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "商城结算系统-ui", "王丽英", "", "");
new pClass().init(true, "ui", "7077", "", "cuishou-ui-new", true, "data", null, "src/Config/config.jsx", "npm run dist", "node7", 1, "催收系统-ui", "李斌", "", "");
new pClass().init(true, "ui", "7078", "", "ka-factory-ui", true, "ui", null, "src/config/env.config.js", "npm run build", "node7", 1, "KA工厂-ui", "张振武", "", "");
new pClass().init(true, "ui", "7080", "", "new-mall-ui", true, "ui", null, "src/app/config/env.config.js", "npm run qa", "node7", 1, "微信商城-ui", "郑少文,周珊", "", "");
// node
new pClass().init(true, "node", "7018", "", "AppBackend", false, "QG", null, "config/environment/test.js", "forever start -a -s --uid AppBackend bin/www", null, 1, "APP后台服务-server", "", "forever stop AppBackend", "");
new pClass().init(true, "node", "7041", "", "activity-op", false, "QG", null, "src/config.js", "sh start.sh", null, 1, "优惠券中心-server", "", "sh stop.sh", "");
......@@ -222,6 +224,15 @@ configFunction.prototype = {
}
}
}
//tower add
module.exports={
java : java_projects,
node : node_projects,
python : python_projects,
ui : ui_projects
}
var F = new configFunction();
if (param["type"] == "") {
......
......@@ -48,3 +48,9 @@ rm -rf /tmp/*
echo "晴空 /home/quant_group/zookeeper-3.4.8/logs/version-2"
rm -rf /home/quant_group/zookeeper-3.4.8/logs/version-2/*
echo "清空pm2"
cd ~/.pm2
>pm2.log
cd ./logs
rm -rf *
......@@ -26,6 +26,14 @@ function addFileHead()
echo "local_port = 8099" >> $1
echo "subdomain = auth-center-38" >> $1
echo " " >> $1
echo "[local]" >> $1
echo "type = http" >> $1
echo "local_ip = 127.0.0.1" >> $1
echo "local_port = 10081" >> $1
echo "subdomain = " >> $1
echo " " >> $1
}
addFileHead $filename
......
......@@ -49,6 +49,9 @@ add_vhost /pay_center
add_vhost backend
add_vhost /trans_order
add_vhost /user_register
add_vhost notify
add_vhost SILKROAD
#add_vhost baitiao_zhitou
#add exchange
add_exchange / hello-exchange direct
......@@ -79,6 +82,7 @@ add_exchange spider_center feature_save direct
add_exchange feature feature_save direct
add_exchange /trans_order trans_order_exchange direct
add_exchange /user_register user_register_exchange direct
add_exchange notify notify-control direct
#add_exchange baitiao_zhitou btzt_orderStatus_exc direct
#add_exchange baitiao_zhitou btzt_repay_rewrite_exc direct
#add_exchange baitiao_zhitou btzt_sendfund_exc direct
......@@ -160,6 +164,7 @@ add_queues spider_center feature_calculate
add_queues feature feature_calculate
add_queues /trans_order trans_order_queue
add_queues /user_register user_register_queue
add_queues notify notify
#add_queues baitiao_zhitou btzt_orderStatus_queue
#add_queues baitiao_zhitou btzt_repay_rewrite_queue
#add_queues baitiao_zhitou btzt_sendfund_queue
......@@ -194,6 +199,7 @@ add_binding /loan_order loan_order_exchange loan_state_msg_queue loan_state_msg
add_binding /trans_order trans_order_exchange trans_order_queue trans-routing-key
add_binding /loan_order loan_repay_status repay_status_urge repayment_status
add_binding /loan_order loan_repay_status push_urge push_urge
add_binding notify notify-control notify notify
#add_binding baitiao_zhitou btzt_repay_rewrite_exc order_approval_query_queue btzt_repay_rewrite_route
#add_binding baitiao_zhitou order_approval_query_exchange order_approval_query_queue order_approval_query_routing
#add_binding baitiao_zhitou delay_order_approval_query_exchange delay_order_approval_query_queue delay_order_approval_query_routing
......
#bin/bash
redis-server redis1.conf
redis-server redis2.conf
redis-server redis3.conf
redis-server redis4.conf
redis-server redis5.conf
redis-server /home/quant_group/redis/redis1.conf
redis-server /home/quant_group/redis/redis2.conf
redis-server /home/quant_group/redis/redis3.conf
redis-server /home/quant_group/redis/redis4.conf
redis-server /home/quant_group/redis/redis5.conf
#!/bin/bash
evn_ip=$1
env_ip=$1
dev_appid=$2
dev_secury=$3
user_url=$4
pay_url=$5
base_path=/home/sub_config_file_dont_rm
echo "
evn_ip:$evn_ip
env_ip:$env_ip
dev_appid:$dev_appid
dev_secury:$dev_secury
user_url:$user_url
......@@ -23,9 +23,9 @@ expect -c "
set timeout 10
spawn ssh root@192.168.4.3
expect \"]#\"
send \"sed -i \\\"N;s#$source_str#$target_str#g\\\" $base_path/$ip_host/$type_/$file_name\r\"
send \"sed -i "s#$source_str#$target_str#g" $base_path/$ip_host/$type_/$file_name\r\"
expect \"]#\"
send \"sed -i \\\"N;s#$source_str#$target_str#g\\\" $base_path/$ip_host/public/$type_/$file_name\r\"
send \"sed -i "s#$source_str#$target_str#g" $base_path/$ip_host/public/$type_/$file_name\r\"
expect \"]#\"
send \"exit\r\"
expect eof;"
......@@ -33,11 +33,21 @@ expect -c "
}
echo "部署时间大约需要10分钟,请确保重启应用时,配置文件不再更改。。。"
echo "step 1 更改配置文件"
tranceConfig java "wechat.appid=.*" "wechat.appid=$dev_appid" "$evn_ip" "xyqb-user2.properties"
tranceConfig java "h5-ui.url=.*" "h5-ui.url=http://$pay_url" "$evn_ip" "xyqb.properties"
tranceConfig ui "weixinAppid:.*" "weixinAppid:'$dev_appid'," "$evn_ip" "xyqb-user-ui.js"
tranceConfig java "wechat.secret=.*" "wechat.secret=$dev_secury" "$evn_ip" "xyqb-user2.properties"
tranceConfig ui "wechattest.xyqb.com" "$user_url" "$evn_ip" "xyqb-user-ui.js"
#tranceConfig java "wechat.appid=.*" "wechat.appid=$dev_appid" "$env_ip" "xyqb-user2.properties"
#tranceConfig java "wechat.secret=.*" "wechat.secret=$dev_secury" "$env_ip" "xyqb-user2.properties"
#tranceConfig java "h5-ui.url=.*" "h5-ui.url=http://$pay_url" "$env_ip" "xyqb.properties"
#tranceConfig ui "weixinAppid:.*" "weixinAppid:\'$dev_appid\'," "$env_ip" "xyqb-user-ui.js"
#tranceConfig ui "wechattest.xyqb.com" "$user_url" "$env_ip" "xyqb-user-ui.js"
ssh root@192.168.4.3 "sed -i \"s#wechat.appid=.*#wechat.appid=$dev_appid#g\" $base_path/$env_ip/java/xyqb-user2.properties"
ssh root@192.168.4.3 "sed -i \"s#wechat.appid=.*#wechat.appid=$dev_appid#g\" $base_path/$env_ip/public/java/xyqb-user2.properties"
ssh root@192.168.4.3 "sed -i \"s#wechat.secret=.*#wechat.secret=$dev_secury#g\" $base_path/$env_ip/java/xyqb-user2.properties"
ssh root@192.168.4.3 "sed -i \"s#wechat.secret=.*#wechat.secret=$dev_secury#g\" $base_path/$env_ip/public/java/xyqb-user2.properties"
ssh root@192.168.4.3 "sed -i \"s#h5-ui.url=.*#h5-ui.url=http://$pay_url#g\" $base_path/$env_ip/java/xyqb.properties"
ssh root@192.168.4.3 "sed -i \"s#wechat.secret=.*#wechat.secret=$dev_secury#g\" $base_path/$env_ip/public/java/xyqb.properties"
ssh root@192.168.4.3 "sed -i \"s#weixinAppid:.*#weixinAppid:\'$dev_appid\',#g\" $base_path/$env_ip/ui/xyqb-user-ui.js"
ssh root@192.168.4.3 "sed -i \"s#weixinAppid:.*#weixinAppid:\'$dev_appid\',#g\" $base_path/$env_ip/public/ui/xyqb-user-ui.js"
ssh root@192.168.4.3 "sed -i \"s#wechattest.xyqb.com#$user_url#g\" $base_path/$env_ip/ui/xyqb-user-ui.js"
ssh root@192.168.4.3 "sed -i \"s#wechattest.xyqb.com#$user_url#g\" $base_path/$env_ip/public/ui/xyqb-user-ui.js"
echo "step 2 重新部署环境"
function reBuildProject(){
expect -c "
......@@ -57,9 +67,9 @@ function reBuildProject(){
send \"exit\r\"
expect eof;"
}
reBuildProject "xyqb-user-ui" "$evn_ip"
reBuildProject "xyqb-user2" "$evn_ip"
reBuildProject "xyqb" "$evn_ip"
reBuildProject "xyqb-user-ui" "$env_ip"
reBuildProject "xyqb-user2" "$env_ip"
reBuildProject "xyqb" "$env_ip"
echo "部署结束,如果之后修改代码,部署project后,请重新执行该部署脚本,否则有可能出现测试环境配置文件被回退的可能。"
......
#!/bin/bash
scriptname=$(basename $0)
lock="/var/run/${scriptname}"
exec 200>$lock
#flock -n 200 || {echo "sub.sh 正在被其他人执行,请稍后再试" && exit 1}
#flock -n 200 || exit 1
flock -n 200
if [ $? -ne 0 ];then
_p=`ps aux | grep $scriptname | grep -v grep | head -n 1 |awk '{print $2}'`
echo "$scriptname 正在被其他人执行,进程号:$_p,预计时间一分钟,请稍后再试~"
exit 1
fi
## The code:
pid=$$
echo $pid 1>&200
IP_host_first="192.168.4."
public_ip="q-gp.com" #"139.198.2.95"
pwd_path="/home/qa-deploy-utils/qa_shell_script"
config_server="$pwd_path/config_server"
ips=`cat $config_server/get_env_ip.sh`
counts=`echo $ips | awk '{print NF}'`
mkdir -p /home/sub_config_file_dont_rm
multis=`node $config_server/get_project_config.js -type multi -attr port`
trap "exec 1000>&-;exec 1000<&-;exit 0" 2
tempfifo=$$.fifo
mkfifo /tmp/$tempfifo
exec 1000<>/tmp/$tempfifo
rm -rf /tmp/$tempfifo
for ((i=1; i<=3; i++))
do
echo >&1000
done
echo "共要生成$counts个环境的配置文件"
echo "并发生成3个环境的配置文件,负载最大时为3~"
#for ip_last_num in '15'
for ip_last_num in ${ips[@]}
do
echo "开始生成${IP_host_first}${ip_last_num}"
read -u1000
{
echo "`date +%T:%N` 开始生成 ${IP_host_first}${ip_last_num}"
cd /home/sub_config_file_dont_rm
mkdir -p ${IP_host_first}${ip_last_num}
cd ${IP_host_first}${ip_last_num}
......@@ -70,7 +104,7 @@ do
pro=`echo $multi | awk -F '|' '{print $1}'`
port=`echo $multi | awk -F '|' '{print $2}'`
#find $dir/public/ -type f -print | xargs -i sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" {}
echo "sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/*"
#echo "sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/*"
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/java/*
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/node/*
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/ui/*
......@@ -85,8 +119,12 @@ do
mkdir -p $dir/pem_file
cp -rf /home/config_files/pem_file/* $dir/pem_file/
# sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/nginx_conf.d/*
echo "结束${IP_host_first}${ip_last_num}"
echo "`date +%T:%N` 结束 ${IP_host_first}${ip_last_num}"
echo "---------"
echo >&1000
}&
done
wait
echo "sh /home/qa-deploy-utils/qa_shell_script/exception_sub_shell.sh"
sh /home/qa-deploy-utils/qa_shell_script/exception_sub_shell.sh
#!/bin/bash
IP_host_first="192.168.4."
public_ip="q-gp.com" #"139.198.2.95"
pwd_path="/home/qa-deploy-utils/qa_shell_script"
config_server="$pwd_path/config_server"
ips=`cat $config_server/get_env_ip.sh`
mkdir -p /home/sub_config_file_dont_rm
multis=`node $config_server/get_project_config.js -type multi -attr port`
#for ip_last_num in '15'
for ip_last_num in ${ips[@]}
do
echo "开始生成${IP_host_first}${ip_last_num}"
cd /home/sub_config_file_dont_rm
mkdir -p ${IP_host_first}${ip_last_num}
cd ${IP_host_first}${ip_last_num}
dir=`pwd`
#java项目发布
mkdir -p $dir/java
mkdir -p $dir/public/java
cp -rf /home/config_files/java/* $dir/java/
cp -rf /home/config_files/java/* $dir/public/java/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/java/*
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/public/java/*
sed -i "s/target_mq_host_name/${IP_host_first}${ip_last_num}/" $dir/java/*
sed -i "s/target_mq_host_name/${IP_host_first}${ip_last_num}/" $dir/public/java/*
#gu-bei的回调接口都改成外网接口
#sed -i "s/callback=http:\/\/${IP_host_first}${ip_last_num}:7006/callback=http:\/\/${public_ip}:${ip_last_num}06/g" $dir/java/gu-bei.properties
#sed -i "s/pay_notify_url=http:\/\/${IP_host_first}${ip_last_num}:7006/pay_notify_url=http:\/\/${public_ip}:${ip_last_num}06/g" $dir/java/gu-bei.properties
sed -i "s/ip_last/$ip_last_num/g" $dir/java/*
sed -i "s/ip_last/$ip_last_num/g" $dir/public/java/*
#python项目发布
mkdir -p $dir/python
cp -rf /home/config_files/python/* $dir/python/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/python/*
sed -i "s/ip_last/$ip_last_num/g" $dir/python/*
#node项目发布
mkdir -p $dir/node
mkdir -p $dir/public/node
cp -rf /home/config_files/node/* $dir/node/
cp -rf /home/config_files/node/* $dir/public/node/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/node/*
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/g" $dir/public/node/*
sed -i "s/ip_last/$ip_last_num/g" $dir/node/*
sed -i "s/ip_last/$ip_last_num/g" $dir/public/node/*
#ui配置发布
mkdir -p $dir/ui
mkdir -p $dir/public/ui
cp -rf /home/config_files/ui/* $dir/ui/
cp -rf /home/config_files/ui/* $dir/public/ui/
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/g" $dir/ui/*
sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/g" $dir/public/ui/*
#if [ $ip_last_num -lt 100 ]; then
# sed -i "s/target_host_name:7/${public_ip}:${ip_last_num}/g" $dir/public/ui/*
#else
#fi
sed -i "s/ip_last/$ip_last_num/g" $dir/public/ui/*
sed -i "s/ip_last/$ip_last_num/g" $dir/ui/*
#替换公网
for multi in ${multis[@]}
do
{
pro=`echo $multi | awk -F '|' '{print $1}'`
port=`echo $multi | awk -F '|' '{print $2}'`
#find $dir/public/ -type f -print | xargs -i sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" {}
echo "sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/*"
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/java/*
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/node/*
sed -i "s/${IP_host_first}${ip_last_num}:$port/${pro}-${ip_last_num}.${public_ip}/g" $dir/public/ui/*
}
done
#find $dir/public/ -type f -print | xargs -i sed -i "s/${IP_host_first}${ip_last_num}/www.${public_ip}/g" {}
#ngxin conf.d发布
mkdir -p $dir/nginx_conf.d
cp -rf /home/config_files/nginx_conf.d/* $dir/nginx_conf.d/
#baitiao pem发布
mkdir -p $dir/pem_file
cp -rf /home/config_files/pem_file/* $dir/pem_file/
# sed -i "s/target_host_name/${IP_host_first}${ip_last_num}/" $dir/nginx_conf.d/*
echo "结束${IP_host_first}${ip_last_num}"
echo "---------"
done
sh /home/qa-deploy-utils/qa_shell_script/exception_sub_shell.sh
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment