Commit 005eca6eb2402d787644b9f186806dc82dd643a6

Authored by 王家文
1 parent f3a490ce
Exists in master and in 1 other branch dev-wjw

faet: 测试服配置和脚本

sh/pre/api-game.sh
... ... @@ -1,91 +0,0 @@
1   - # !/bin/bash
2   -if [ ! -n "$1" ]; then
3   - echo "params error"
4   - exit 1
5   -elif [ $1 != "start" -a $1 != "restart" -a $1 != "stop" ]; then
6   - echo "please input start|stop|restart"
7   - exit 2
8   -fi
9   -env=pre
10   -nowdate=`date +"%Y%m%d%H%M"`
11   -execdir=/home/exec/apigame/api/$nowdate
12   -codedir=/home/code/go/apigame/src
13   -execname=apigame
14   -execnewname=API_GAME_$nowdate
15   -ports=(39080)
16   -codeport=80
17   -echo "${execname} script is begin...."
18   -sleep 1s
19   -# cd $codedir
20   -for i in ${ports[@]};
21   -do
22   - if [ $1 == "start" ];then
23   - userport=`netstat -antp | grep ":${i}"`
24   - if [ ${#userport} -gt 3 ]; then
25   - echo "port ${i} is busy..."
26   - break
27   - fi
28   - fi
29   - if [ $1 == "start" -o $1 == "restart" ];then
30   - #copy new main
31   - cd $codedir
32   - if [ $? -ne 0 ]; then
33   - echo "cd ${codedir} error,port:${i}"
34   - break
35   - fi
36   - execdirpath=$execdir/$i
37   - if [ ! -d $execdirpath ]; then
38   - mkdir -p $execdirpath
39   - if [ $? -ne 0 ]; then
40   - echo "mkdir ${execdirpath} error"
41   - break
42   - fi
43   - cp $execname $execdirpath/${execnewname}_${i}
44   - cp -r conf $execdirpath/
45   - #cp -r ../conf $execdirpath/../
46   - sed -i "s#httpport = ${codeport}#httpport = ${i}#g" $execdirpath/conf/${env}.conf
47   - if [ $? -ne 0 ]; then
48   - echo "sed httpport ${codeport},i:${i} error"
49   - break
50   - fi
51   - sed -i "s#appname = ${execname}#appname = ${execnewname}_${i}#g" $execdirpath/conf/${env}.conf
52   - if [ $? -ne 0 ]; then
53   - echo "sed appname ${execname},i:${i} error"
54   - break
55   - fi
56   - rm -rf app.conf
57   - if [ $? -ne 0 ]; then
58   - echo "delete app.conf i:${i} error"
59   - break
60   - fi
61   - echo "include \"${env}.conf\"" > $execdirpath/conf/app.conf
62   - fi
63   - fi
64   - #kill old port main
65   - if [ $1 == "stop" -o $1 == "restart" ];then
66   - userport=`netstat -antp | grep ":${i}"`
67   - if [ ${#userport} -gt 3 ]; then
68   - kill -9 $(netstat -nlp | grep :${i} | awk '{print $7}' | awk -F"/" '{ print $1 }')
69   - if [ $? -ne 0 ]; then
70   - echo "kill port ${i} success"
71   - break
72   - else
73   - echo "kill port ${i} success"
74   - fi
75   - fi
76   - fi
77   - #start new maini
78   - if [ $1 == "start" -o $1 == "restart" ];then
79   - cd $execdirpath/
80   - nohup ./${execnewname}_${i} >/dev/null 2>$execdirpath/error.log 2>&1 &
81   - if [ $? -ne 0 ]; then
82   - echo "${execnewname}_${i} start error "
83   - break
84   - else
85   - echo "${execnewname}_${i} start ok "
86   - fi
87   - fi
88   - sleep 5s
89   -done
90   -echo "${execname} script is end...."
91   -exit 0
sh/pre/apigame.sh 0 → 100644
... ... @@ -0,0 +1,91 @@
  1 + # !/bin/bash
  2 +if [ ! -n "$1" ]; then
  3 + echo "params error"
  4 + exit 1
  5 +elif [ $1 != "start" -a $1 != "restart" -a $1 != "stop" ]; then
  6 + echo "please input start|stop|restart"
  7 + exit 2
  8 +fi
  9 +env=pre
  10 +nowdate=`date +"%Y%m%d%H%M"`
  11 +execdir=/home/exec/apigame/api/$nowdate
  12 +codedir=/home/code/go/apigame/src
  13 +execname=apigame
  14 +execnewname=API_GAME_$nowdate
  15 +ports=(39080)
  16 +codeport=80
  17 +echo "${execname} script is begin...."
  18 +sleep 1s
  19 +# cd $codedir
  20 +for i in ${ports[@]};
  21 +do
  22 + if [ $1 == "start" ];then
  23 + userport=`netstat -antp | grep ":${i}"`
  24 + if [ ${#userport} -gt 3 ]; then
  25 + echo "port ${i} is busy..."
  26 + break
  27 + fi
  28 + fi
  29 + if [ $1 == "start" -o $1 == "restart" ];then
  30 + #copy new main
  31 + cd $codedir
  32 + if [ $? -ne 0 ]; then
  33 + echo "cd ${codedir} error,port:${i}"
  34 + break
  35 + fi
  36 + execdirpath=$execdir/$i
  37 + if [ ! -d $execdirpath ]; then
  38 + mkdir -p $execdirpath
  39 + if [ $? -ne 0 ]; then
  40 + echo "mkdir ${execdirpath} error"
  41 + break
  42 + fi
  43 + cp $execname $execdirpath/${execnewname}_${i}
  44 + cp -r conf $execdirpath/
  45 + #cp -r ../conf $execdirpath/../
  46 + sed -i "s#httpport = ${codeport}#httpport = ${i}#g" $execdirpath/conf/${env}.conf
  47 + if [ $? -ne 0 ]; then
  48 + echo "sed httpport ${codeport},i:${i} error"
  49 + break
  50 + fi
  51 + sed -i "s#appname = ${execname}#appname = ${execnewname}_${i}#g" $execdirpath/conf/${env}.conf
  52 + if [ $? -ne 0 ]; then
  53 + echo "sed appname ${execname},i:${i} error"
  54 + break
  55 + fi
  56 + rm -rf app.conf
  57 + if [ $? -ne 0 ]; then
  58 + echo "delete app.conf i:${i} error"
  59 + break
  60 + fi
  61 + echo "include \"${env}.conf\"" > $execdirpath/conf/app.conf
  62 + fi
  63 + fi
  64 + #kill old port main
  65 + if [ $1 == "stop" -o $1 == "restart" ];then
  66 + userport=`netstat -antp | grep ":${i}"`
  67 + if [ ${#userport} -gt 3 ]; then
  68 + kill -9 $(netstat -nlp | grep :${i} | awk '{print $7}' | awk -F"/" '{ print $1 }')
  69 + if [ $? -ne 0 ]; then
  70 + echo "kill port ${i} success"
  71 + break
  72 + else
  73 + echo "kill port ${i} success"
  74 + fi
  75 + fi
  76 + fi
  77 + #start new maini
  78 + if [ $1 == "start" -o $1 == "restart" ];then
  79 + cd $execdirpath/
  80 + nohup ./${execnewname}_${i} >/dev/null 2>$execdirpath/error.log 2>&1 &
  81 + if [ $? -ne 0 ]; then
  82 + echo "${execnewname}_${i} start error "
  83 + break
  84 + else
  85 + echo "${execnewname}_${i} start ok "
  86 + fi
  87 + fi
  88 + sleep 5s
  89 +done
  90 +echo "${execname} script is end...."
  91 +exit 0
... ...
sh/pre/auto.sh
... ... @@ -2,33 +2,26 @@
2 2 if [ ! -n "$1" ]; then
3 3 echo "params error"
4 4 exit 1
5   -elif [ $1 != "api-qixi" ]; then
6   - echo "please input api-qixi"
7   - exit 2
8   -fi
9   -if [ ! -n "$2" ]; then
10   - echo "params error"
11   - exit 1
12   -elif [ $2 != "start" -a $2 != "restart" -a $2 != "stop" ]; then
  5 +elif [ $1 != "start" -a $1 != "restart" -a $1 != "stop" ]; then
13 6 echo "please input start|stop|restart"
14 7 exit 2
15 8 fi
16 9  
17 10  
18   -sh /sh/qixi/git.sh
  11 +sh /sh/apigame/git.sh
19 12 if [ $? -ne 0 ];then
20 13 exit 3
21 14 fi
22 15  
23   -binname=$1
24   -sh /sh/qixi/build.sh ${binname}
  16 +binname=apigame
  17 +sh /sh/apigame/build.sh ${binname}
25 18 if [ $? -ne 0 ];then
26 19 exit 1
27 20 fi
28 21  
29 22  
30 23 sleep 1s
31   -sh /sh/qixi/${1}.sh ${2}
  24 +sh /sh/apigame/$apigame.sh ${1}
32 25 if [ $? -ne 0 ];then
33 26 exit 1
34 27 fi
... ...