Commit 09fdeeb5 authored by tywldx's avatar tywldx

temp

parent 0eee188c
......@@ -7,10 +7,10 @@ config_server="$pwd_path/config_server"
project_type=`node $config_server/get_project_config.js -name $project_name -attr type`
project_path=`cat $config_server/project_path.sh`
config_path=`cat $config_server/config_path.sh`
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
profile=test
time=`date +%Y_%m_%d_%H_%M_%S`
# node4_path=`cat $config_server/node_4_path.sh`
# node7_path=`cat $config_server/node_7_path.sh`
# profile=test
# time=`date +%Y_%m_%d_%H_%M_%S`
# function restartJavaProject()
# {
......@@ -71,114 +71,117 @@ time=`date +%Y_%m_%d_%H_%M_%S`
# fi
# }
function restartNodeProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
stop_command_=`node $config_server/get_project_config.js -name $project -attr command2`
stop_command=${stop_command_//\^/ }
sh $config_server/show_info.sh $project 重新启动 $desc $2
cd $project_path/$project
$stop_command
# forever stop $project
# forever stop $project-www
# pm2 stop $project
start_command_=`node $config_server/get_project_config.js -name $project -attr command`
start_command=${start_command_//\^/ }
$start_command
if [ $? -ne 0 ]
then
echo "Fail to start"
exit -1
fi
# setup_path_temp=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "app.js" -print`
# echo "------setup_path_temp:$setup_path_temp"
#
# echo `forever start -a -s --uid $project ${setup_path_temp}`
#
# setup_path_temp_for_appbackent=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "www" -print`
# if [ -n "$setup_path_temp_for_appbackent" ];then
# echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
# echo `forever start -a -s --uid $project-www ${setup_path_temp_for_appbackent}`
# function restartNodeProject()
# {
# project=$1
# desc=`node $config_server/get_project_config.js -name $project -attr desc`
# stop_command_=`node $config_server/get_project_config.js -name $project -attr command2`
# stop_command=${stop_command_//\^/ }
# sh $config_server/show_info.sh $project 重新启动 $desc $2
# cd $project_path/$project
# $stop_command
# # forever stop $project
# # forever stop $project-www
# # pm2 stop $project
# start_command_=`node $config_server/get_project_config.js -name $project -attr command`
# start_command=${start_command_//\^/ }
# $start_command
# if [ $? -ne 0 ]
# then
# echo "Fail to start"
# exit -1
# fi
}
# # setup_path_temp=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "app.js" -print`
# # echo "------setup_path_temp:$setup_path_temp"
# #
# # echo `forever start -a -s --uid $project ${setup_path_temp}`
# #
# # setup_path_temp_for_appbackent=`find ./ -maxdepth 2 -path "./node_modules" -prune -o -type f -name "www" -print`
# # if [ -n "$setup_path_temp_for_appbackent" ];then
# # echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
# # echo `forever start -a -s --uid $project-www ${setup_path_temp_for_appbackent}`
# # fi
# }
function restartPythonProject()
{
project=$1
desc=`node $config_server/get_project_config.js -name $project -attr desc`
port=`node $config_server/get_project_config.js -name $project -attr port`
sh $config_server/show_info.sh $project 重新启动 $desc $2
cd $project_path/$project
setup_path_temp=`find ./ -name "run.py"`
python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
P_UUID=`ps -ef|grep port=$port |grep -v 'grep'|awk '{print $2}'`
if [[ "${P_UUID}" != "" ]];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 3
fi
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &`
}
# function restartPythonProject()
# {
# project=$1
# desc=`node $config_server/get_project_config.js -name $project -attr desc`
# port=`node $config_server/get_project_config.js -name $project -attr port`
# sh $config_server/show_info.sh $project 重新启动 $desc $2
# cd $project_path/$project
# setup_path_temp=`find ./ -name "run.py"`
# python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
#
# P_UUID=`ps -ef|grep port=$port |grep -v 'grep'|awk '{print $2}'`
# if [[ "${P_UUID}" != "" ]];then
# echo "-----KILL $project PPID=${P_UUID}"
# echo `kill -9 ${P_UUID}`
# sleep 3
# fi
#
# echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
# echo `python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &`
#
# }
function restartUiProject()
{
nginx -t; nginx -s reload
}
# function restartUiProject()
# {
# nginx -t; nginx -s reload
# }
#acknowledge whether the deploy start OK
function ack()
{
ack_phrase="$1"
log_path="$2"
max_wait_log_generate_time="$3"
max_wait_ack_time="$4"
wait_log_generate_time=0
wait_ack_time=0
echo "begin acknowledge whether the deploy start OK, ACK_PHRASE=${ack_phrase}, log_path=${log_path}"
while [ ! -f ${log_path} ]
do
echo "wait_log_generate_time is ${wait_log_generate_time}, max_wait_log_generate_time is ${max_wait_log_generate_time} "
if ((${wait_log_generate_time}>${max_wait_log_generate_time}))
then
echo "the log generated time exceed the limit"
exit -1
fi
echo 'the log does not exist, wait for 5 seconds'
sleep 5
let "wait_log_generate_time+=5"
done
echo "listen for the log ack..."
for ((i=0;;))
do
bootstrap_flag=`cat ${log_path} |grep "${ack_phrase}"| wc -l`
if [ "${bootstrap_flag}" = 0 ] && [ "${max_wait_ack_time}" -gt "${wait_ack_time}" ]
then
sleep 5
let "wait_ack_time+=5"
echo "waiting for bootstrap flag for ${wait_ack_time}"
elif [ "${bootstrap_flag}" = 1 ]
then
echo "server is start~"
exit 0
else
echo "server not startup in ${max_wait_ack_time} seconds..."
exit -1
fi
done
}
# function ack()
# {
# ack_phrase="$1"
# log_path="$2"
# max_wait_log_generate_time="$3"
# max_wait_ack_time="$4"
# wait_log_generate_time=0
# wait_ack_time=0
# echo "begin acknowledge whether the deploy start OK, ACK_PHRASE=${ack_phrase}, log_path=${log_path}"
# while [ ! -f ${log_path} ]
# do
# echo "wait_log_generate_time is ${wait_log_generate_time}, max_wait_log_generate_time is ${max_wait_log_generate_time} "
# if ((${wait_log_generate_time}>${max_wait_log_generate_time}))
# then
# echo "the log generated time exceed the limit"
# exit -1
# fi
# echo 'the log does not exist, wait for 5 seconds'
# sleep 5
# let "wait_log_generate_time+=5"
# done
# echo "listen for the log ack..."
# for ((i=0;;))
# do
# bootstrap_flag=`cat ${log_path} |grep "${ack_phrase}"| wc -l`
# if [ "${bootstrap_flag}" = 0 ] && [ "${max_wait_ack_time}" -gt "${wait_ack_time}" ]
# then
# sleep 5
# let "wait_ack_time+=5"
# echo "waiting for bootstrap flag for ${wait_ack_time}"
# elif [ "${bootstrap_flag}" = 1 ]
# then
# echo "server is start~"
# exit 0
# else
# echo "server not startup in ${max_wait_ack_time} seconds..."
# exit -1
# fi
# done
# }
if [ "$project_type" = "java" ]; then
sh $pwd_path/base_script/restartJava.sh $project_name $config_server $project_path
# restartJavaProject $project_name $3
elif [ "$project_type" = "node" ]; then
restartNodeProject $project_name $3
sh $pwd_path/base_script/restartNode.sh $project_name $config_server $project_path
# restartNodeProject $project_name $3
elif [ "$project_type" = "python" ]; then
restartPythonProject $project_name $3
sh $pwd_path/base_script/restartPython.sh $project_name $config_server $project_path
# restartPythonProject $project_name $3
elif [ "$project_type" = "ui" ]; then
restartUiProject $project_name $3
sh $pwd_path/base_script/restartUi.sh $project_name $config_server $project_path
# restartUiProject $project_name $3
fi
#!/bin/bash
project=$1
config_server=$2
project_path=$3
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
desc=`node $config_server/get_project_config.js -name $project -attr desc`
stop_command_=`node $config_server/get_project_config.js -name $project -attr command2`
stop_command=${stop_command_//\^/ }
sh $config_server/show_info.sh $project 重新启动 $desc $2
cd $project_path/$project
$stop_command
start_command_=`node $config_server/get_project_config.js -name $project -attr command`
start_command=${start_command_//\^/ }
$start_command
if [ $? -ne 0 ]
then
echo "Fail to start"
exit -1
fi
\ No newline at end of file
#!/bin/bash
project=$1
config_server=$2
project_path=$3
desc=`node $config_server/get_project_config.js -name $project -attr desc`
port=`node $config_server/get_project_config.js -name $project -attr port`
sh $config_server/show_info.sh $project 重新启动 $desc $2
cd $project_path/$project
setup_path_temp=`find ./ -name "run.py"`
python_project_path=$project_path/$project${setup_path_temp/\.\//\/}
P_UUID=`ps -ef|grep port=$port |grep -v 'grep'|awk '{print $2}'`
if [[ "${P_UUID}" != "" ]];then
echo "-----KILL $project PPID=${P_UUID}"
echo `kill -9 ${P_UUID}`
sleep 3
fi
echo "-----project:$project while be run command: python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &"
echo `python $python_project_path --mode=beta --port=$port > /dev/null 2>&1 &`
\ No newline at end of file
#!/bin/bash
project=$1
config_server=$2
project_path=$3
node4_path=`cat $config_server/node_4_path.sh`
node7_path=`cat $config_server/node_7_path.sh`
nginx -t; nginx -s reload
\ No newline at end of file
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