Skip to content

Commit 373f43d

Browse files
authored
Merge pull request #1 from zouyx/feature/fixAutoTest
Fix: Auto test problems
2 parents d094fd1 + 8ca831a commit 373f43d

File tree

290 files changed

+12250
-10858
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+12250
-10858
lines changed
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
19+
APP_NAME="APPLICATION_NAME"
20+
APP_ARGS=""
21+
SLEEP_INTERVAL=5
22+
MAX_LIFETIME=4000
23+
24+
PROJECT_HOME=""
25+
OS_NAME=`uname`
26+
if [[ ${OS_NAME} != "Windows" ]]; then
27+
PROJECT_HOME=`pwd`
28+
PROJECT_HOME=${PROJECT_HOME}"/"
29+
else
30+
APP_NAME="APPLICATION_NAME.exe"
31+
fi
32+
33+
export CONF_CONSUMER_FILE_PATH=${PROJECT_HOME}"TARGET_CONF_FILE"
34+
export APP_LOG_CONF_FILE=${PROJECT_HOME}"TARGET_LOG_CONF_FILE"
35+
# export GOTRACEBACK=system
36+
# export GODEBUG=gctrace=1
37+
38+
usage() {
39+
echo "Usage: $0 start [conf suffix]"
40+
echo " $0 stop"
41+
echo " $0 term"
42+
echo " $0 restart"
43+
echo " $0 list"
44+
echo " $0 monitor"
45+
echo " $0 crontab"
46+
exit
47+
}
48+
49+
start() {
50+
arg=$1
51+
if [ "$arg" = "" ];then
52+
echo "No registry type! Default client.yml!"
53+
else
54+
export CONF_CONSUMER_FILE_PATH=${CONF_CONSUMER_FILE_PATH//\.yml/\_$arg\.yml}
55+
fi
56+
if [ ! -f "${CONF_CONSUMER_FILE_PATH}" ];then
57+
echo $CONF_CONSUMER_FILE_PATH" is not existing!"
58+
return
59+
fi
60+
APP_LOG_PATH=${PROJECT_HOME}"logs/"
61+
mkdir -p ${APP_LOG_PATH}
62+
APP_BIN=${PROJECT_HOME}sbin/${APP_NAME}
63+
chmod u+x ${APP_BIN}
64+
# CMD="nohup ${APP_BIN} ${APP_ARGS} >>${APP_NAME}.nohup.out 2>&1 &"
65+
CMD="${APP_BIN}"
66+
eval ${CMD}
67+
R=$?
68+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'`
69+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
70+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'`
71+
fi
72+
CUR=`date +%FT%T`
73+
if [ "${PID}" != "" ]; then
74+
for p in ${PID}
75+
do
76+
echo "start ${APP_NAME} ( pid =" ${p} ") at " ${CUR}
77+
done
78+
fi
79+
return $R
80+
}
81+
82+
stop() {
83+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'`
84+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
85+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'`
86+
fi
87+
if [ "${PID}" != "" ];
88+
then
89+
for ps in ${PID}
90+
do
91+
echo "kill -SIGINT ${APP_NAME} ( pid =" ${ps} ")"
92+
kill -2 ${ps}
93+
done
94+
fi
95+
}
96+
97+
98+
term() {
99+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'`
100+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
101+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'`
102+
fi
103+
if [ "${PID}" != "" ];
104+
then
105+
for ps in ${PID}
106+
do
107+
echo "kill -9 ${APP_NAME} ( pid =" ${ps} ")"
108+
kill -9 ${ps}
109+
done
110+
fi
111+
}
112+
113+
list() {
114+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s\n", $1, $2, $9, $10)}'`
115+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
116+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{printf("%s,%s,%s,%s,%s\n", $1, $4, $6, $7, $8)}'`
117+
fi
118+
119+
if [ "${PID}" != "" ]; then
120+
echo "list ${APP_NAME}"
121+
122+
if [[ ${OS_NAME} == "Linux" || ${OS_NAME} == "Darwin" ]]; then
123+
echo "index: user, pid, start, duration"
124+
else
125+
echo "index: PID, WINPID, UID, STIME, COMMAND"
126+
fi
127+
idx=0
128+
for ps in ${PID}
129+
do
130+
echo "${idx}: ${ps}"
131+
((idx ++))
132+
done
133+
fi
134+
}
135+
136+
monitor() {
137+
idx=0
138+
while true; do
139+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'`
140+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
141+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'`
142+
fi
143+
if [[ "${PID}" == "" ]]; then
144+
start
145+
idx=0
146+
fi
147+
148+
((LIFE=idx*${SLEEP_INTERVAL}))
149+
echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds."
150+
((idx ++))
151+
sleep ${SLEEP_INTERVAL}
152+
done
153+
}
154+
155+
crontab() {
156+
idx=0
157+
while true; do
158+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $2}'`
159+
if [[ ${OS_NAME} != "Linux" && ${OS_NAME} != "Darwin" ]]; then
160+
PID=`ps aux | grep -w ${APP_NAME} | grep -v grep | awk '{print $1}'`
161+
fi
162+
if [[ "${PID}" == "" ]]; then
163+
start
164+
idx=0
165+
fi
166+
167+
((LIFE=idx*${SLEEP_INTERVAL}))
168+
echo "${APP_NAME} ( pid = " ${PID} ") has been working in normal state for " $LIFE " seconds."
169+
((idx ++))
170+
sleep ${SLEEP_INTERVAL}
171+
if [[ ${LIFE} -gt ${MAX_LIFETIME} ]]; then
172+
kill -9 ${PID}
173+
fi
174+
done
175+
}
176+
177+
opt=$1
178+
case C"$opt" in
179+
Cstart)
180+
start $2
181+
;;
182+
Cstop)
183+
stop
184+
;;
185+
Cterm)
186+
term
187+
;;
188+
Crestart)
189+
term
190+
start $2
191+
;;
192+
Clist)
193+
list
194+
;;
195+
Cmonitor)
196+
monitor
197+
;;
198+
Ccrontab)
199+
crontab
200+
;;
201+
C*)
202+
usage
203+
;;
204+
esac
205+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
TARGET_EXEC_NAME="user_info_client"
19+
# BUILD_PACKAGE="dubbogo-examples/user-info/client/app"
20+
BUILD_PACKAGE="app"
21+
22+
TARGET_CONF_FILE="conf/client.yml"
23+
TARGET_LOG_CONF_FILE="conf/log.yml"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
rm -rf target/
19+
20+
PROJECT_HOME=`pwd`
21+
TARGET_FOLDER=${PROJECT_HOME}/target/${GOOS}
22+
23+
TARGET_SBIN_NAME=${TARGET_EXEC_NAME}
24+
version=`cat app/version.go | grep Version | grep -v "Apache" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}'`
25+
if [[ ${GOOS} == "windows" ]]; then
26+
TARGET_SBIN_NAME=${TARGET_SBIN_NAME}.exe
27+
fi
28+
TARGET_NAME=${TARGET_FOLDER}/${TARGET_SBIN_NAME}
29+
if [[ $PROFILE = "test" ]]; then
30+
# GFLAGS=-gcflags "-N -l" -race -x -v # -x会把go build的详细过程输出
31+
# GFLAGS=-gcflags "-N -l" -race -v
32+
# GFLAGS="-gcflags \"-N -l\" -v"
33+
cd ${BUILD_PACKAGE} && GO111MODULE=on go build -gcflags "-N -l" -i -o ${TARGET_NAME} && cd -
34+
else
35+
# -s去掉符号表(然后panic时候的stack trace就没有任何文件名/行号信息了,这个等价于普通C/C++程序被strip的效果),
36+
# -w去掉DWARF调试信息,得到的程序就不能用gdb调试了。-s和-w也可以分开使用,一般来说如果不打算用gdb调试,
37+
# -w基本没啥损失。-s的损失就有点大了。
38+
cd ${BUILD_PACKAGE} && GO111MODULE=on go build -ldflags "-w" -i -o ${TARGET_NAME} && cd -
39+
fi
40+
41+
TAR_NAME=${TARGET_EXEC_NAME}-${version}-`date "+%Y%m%d-%H%M"`-${PROFILE}
42+
43+
mkdir -p ${TARGET_FOLDER}/${TAR_NAME}
44+
45+
SBIN_DIR=${TARGET_FOLDER}/${TAR_NAME}/sbin
46+
BIN_DIR=${TARGET_FOLDER}/${TAR_NAME}
47+
CONF_DIR=${TARGET_FOLDER}/${TAR_NAME}/conf
48+
49+
mkdir -p ${SBIN_DIR}
50+
mkdir -p ${CONF_DIR}
51+
52+
mv ${TARGET_NAME} ${SBIN_DIR}
53+
cp -r assembly/bin ${BIN_DIR}
54+
# modify APPLICATION_NAME
55+
# OS=`uname`
56+
# if [[ $OS=="Darwin" ]]; then
57+
if [ "$(uname)" == "Darwin" ]; then
58+
sed -i "" "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/*
59+
else
60+
sed -i "s~APPLICATION_NAME~${TARGET_EXEC_NAME}~g" ${BIN_DIR}/bin/*
61+
fi
62+
# modify TARGET_CONF_FILE
63+
if [ "$(uname)" == "Darwin" ]; then
64+
sed -i "" "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/*
65+
else
66+
sed -i "s~TARGET_CONF_FILE~${TARGET_CONF_FILE}~g" ${BIN_DIR}/bin/*
67+
fi
68+
# modify TARGET_LOG_CONF_FILE
69+
if [ "$(uname)" == "Darwin" ]; then
70+
sed -i "" "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/*
71+
else
72+
sed -i "s~TARGET_LOG_CONF_FILE~${TARGET_LOG_CONF_FILE}~g" ${BIN_DIR}/bin/*
73+
fi
74+
75+
cp -r profiles/${PROFILE}/* ${CONF_DIR}
76+
77+
cd ${TARGET_FOLDER}
78+
79+
tar czf ${TAR_NAME}.tar.gz ${TAR_NAME}/*
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
19+
20+
set -e
21+
22+
export GOOS=linux
23+
export GOARCH=amd64
24+
25+
PROFILE=dev
26+
27+
PROJECT_HOME=`pwd`
28+
29+
if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then
30+
. ${PROJECT_HOME}/assembly/common/app.properties
31+
fi
32+
33+
34+
if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then
35+
. ${PROJECT_HOME}/assembly/common/build.sh
36+
fi
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with
5+
# this work for additional information regarding copyright ownership.
6+
# The ASF licenses this file to You under the Apache License, Version 2.0
7+
# (the "License"); you may not use this file except in compliance with
8+
# the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
19+
20+
set -e
21+
22+
export GOOS=linux
23+
export GOARCH=amd64
24+
25+
export PROFILE="release"
26+
export PROJECT_HOME=`pwd`
27+
28+
if [ -f "${PROJECT_HOME}/assembly/common/app.properties" ]; then
29+
. ${PROJECT_HOME}/assembly/common/app.properties
30+
fi
31+
32+
33+
if [ -f "${PROJECT_HOME}/assembly/common/build.sh" ]; then
34+
sh ${PROJECT_HOME}/assembly/common/build.sh
35+
fi

0 commit comments

Comments
 (0)