-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlinux_run.sh
70 lines (54 loc) · 1.31 KB
/
linux_run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# @author EricYonng<120453674@qq.com>
# @brief run svr...
#!/usr/bin/env bash
SCRIPT_PATH="$(cd $(dirname $0); pwd)"
RUN_PATH=${SCRIPT_PATH}/output/gmake
# 设置环境变量LD_LIBRARY_PATH以便启动时能够识别当前目录下的so
export LD_LIBRARY_PATH=${RUN_PATH}:${LD_LIBRARY_PATH}
echo "LD_LIBRARY_PATH:${LD_LIBRARY_PATH}"
if [ $# -lt 1 ]
then
echo "lack of exe name."
exit 1
fi
RUN_NAME="testsuit"
if [ -n "$1" ]
then
RUN_NAME=$1
fi
if [ -n "$2" ]
then
VER="$2"
if [ $VER = "debug" ]
then
RUN_NAME="${RUN_NAME}_debug"
fi
fi
echo "will run process:${RUN_NAME}"
nohup ${RUN_PATH}/${RUN_NAME} > ${RUN_PATH}/${RUN_NAME}.nohup 2>&1 &
GREP_FLAG="${RUN_NAME}"
IS_START=0
echo "wait ${GREP_FLAG} start"
if [ -n "$3" ]
then
echo "wait ($3)seconds ${GREP_FLAG} start"
sleep $3
else
echo "wait (5)seconds ${GREP_FLAG} start"
# 默认等待5秒
sleep 5
fi
while [ $IS_START -eq 0 ]
do
PID_LIST="$(ps -aux |grep ${GREP_FLAG} | sed '/grep/d' | sed '/linux_run/d' | sed '/start/d' | sed '/stop/d' | sed 's/^[^ ]* //' | sed 's/^ *//' | sed 's/ .*$//')"
# PID_LIST=$(ps -e | grep ${GREP_FLAG} | awk '{print $1}')
if [ -n "${PID_LIST}" ]
then
IS_START=1
echo "${GREP_FLAG} started pids:${PID_LIST}."
else
sleep 1
echo "wait ${GREP_FLAG} start"
fi
done
echo "run process success."