Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qa-deploy-utils
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QA
qa-deploy-utils
Commits
1f9e0d3e
Commit
1f9e0d3e
authored
Feb 20, 2017
by
GanSC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
de943a1a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
6 deletions
+148
-6
6_start_by_name.sh
qa_shell_script/6_start_by_name.sh
+148
-6
No files found.
qa_shell_script/6_start_by_name.sh
View file @
1f9e0d3e
#!/bin/bash
project
=
$1
#project=$1
#pwd_path="/home/qa-deploy-utils/qa_shell_script"
#config_server="$pwd_path/config_server"
#project_path=`cat $config_server/project_path.sh`
#function startProject(){
# sh $config_server/show_info.sh $project 重新启动 $desc
# cd $project_path/$project
# P_UUID=`ps -ef|grep ${project}.jar |grep -v 'grep'|awk '{print $2}'`
# if [ -n "${P_UUID}" ];then
# echo "KILL $project PPID=${P_UUID}"
# echo `kill -9 ${P_UUID}`
# sleep 2s
# fi
# echo "重新启动$project服务"
# if [[ $project = "redpacket" ]]; then
# echo `java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t -ts > /dev/null 2>&1 &`
# else
# echo `java -Xmx512m -XX:PermSize64m -Xloggc:/tmp/${project}.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar ${project}.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &`
# fi
#}
#startProject $project
project_name
=
$1
is_public_ip
=
$2
pwd_path
=
"/home/qa-deploy-utils/qa_shell_script"
config_shell_path
=
"
$pwd_path
"
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
`
function
start
Project
()
function
restartJava
Project
()
{
max_wait_log_generate_time
=
50
max_wait_ack_time
=
500
ack_phrase
=
"Started
\
Bootstrap"
project
=
$1
desc
=
`
node
$config_server
/get_project_config.js
-name
$project
-attr
desc
`
sh
$config_server
/show_info.sh
$project
重新启动
$desc
cd
$project_path
/
$project
P_UUID
=
`
ps
-ef
|grep
${
project
}
.jar |grep
-v
'grep'
|awk
'{print $2}'
`
if
[
-n
"
${
P_UUID
}
"
]
;
then
echo
"KILL
$project
PPID=
${
P_UUID
}
"
echo
"
-----
KILL
$project
PPID=
${
P_UUID
}
"
echo
`
kill
-9
${
P_UUID
}
`
sleep
2s
fi
echo
"重新启动
$project
服务"
if
[[
$project
=
"redpacket"
]]
;
then
echo
"-----project:
$project
while be run command: java -Xmx256m -XX:PermSize64m -Xloggc:/tmp/
${
project
}
.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -jar
${
project
}
.jar --worker 1 --currentWorker 1 -t > /dev/null 2>&1 &"
log_name
=
`
node
$config_server
/get_project_config.js
-name
$project
-attr
log_name
`
mv
$project_path
/logs/
$log_name
$project_path
/logs/logs_back/
$project
-
$time
.log
if
[[
$project
==
"redpacket"
]]
;
then
echo
`
java
-Xmx512m
-XX
:PermSize64m
-Xloggc
:/tmp/
${
project
}
.log
-XX
:+PrintGCDetails
-XX
:+PrintGCTimeStamps
-jar
${
project
}
.jar
--worker
1
--currentWorker
1
-t
-ts
>
/dev/null 2>&1 &
`
else
echo
`
java
-Xmx512m
-XX
:PermSize64m
-Xloggc
:/tmp/
${
project
}
.log
-XX
:+PrintGCDetails
-XX
:+PrintGCTimeStamps
-jar
${
project
}
.jar
--worker
1
--currentWorker
1
-t
>
/dev/null 2>&1 &
`
fi
#sleep 30s
ack
"
$ack_phrase
"
$project_path
/logs/
$log_name
${
max_wait_log_generate_time
}
${
max_wait_ack_time
}
}
function
restartNodeProject
()
{
project
=
$1
desc
=
`
node
$config_server
/get_project_config.js
-name
$project
-attr
desc
`
sh
$config_server
/show_info.sh
$project
重新启动
$desc
cd
$project_path
/
$project
forever stop
$project
forever stop
$project
-www
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
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
}
#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
}
startProject
$project
if
[
"
$project_type
"
=
"java"
]
;
then
restartJavaProject
$project_name
elif
[
"
$project_type
"
=
"node"
]
;
then
restartNodeProject
$project_name
elif
[
"
$project_type
"
=
"python"
]
;
then
restartPythonProject
$project_name
elif
[
"
$project_type
"
=
"ui"
]
;
then
restartUiProject
$project_name
fi
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment