-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathstart.sh
executable file
·44 lines (33 loc) · 983 Bytes
/
start.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
#!/bin/bash
ROOT_DIR=$(pwd)
PROCESSES_DIR=$ROOT_DIR/processes
CONFIG_DIR=$ROOT_DIR/config
LOG_DIR=$ROOT_DIR/log
PROCESS_EXIST=0
PROCESS_NOT_EXIST=1
ulimit -c unlimited
PROCESS_LIST=("router 1" "world 1" "gateway 1")
#PROCESS_LIST=("router 1" "dbcached 1" "session 1" "func 1" "world 1" "world 2" "gateway 1")
function checkProcessExist()
{
RESULT=$(ps -x |grep _exec |grep server |awk '{print $5 $6}' |grep "$1" |grep "$2")
if [ "$RESULT" == "" ]
then
return $PROCESS_NOT_EXIST
else
return $PROCESS_EXIST
fi
}
for ((i=0; i<${#PROCESS_LIST[*]}; i++)); do
PROCESS=${PROCESS_LIST[$i]}
NAME=$(awk -v process="$PROCESS" 'BEGIN{print process}' |awk '{print $1}')
NUM=$(awk -v process="$PROCESS" 'BEGIN{print process}' |awk '{print $2}')
checkProcessExist $NAME $NUM
if [[ $? -eq "$PROCESS_NOT_EXIST" ]]
then
$PROCESSES_DIR/$NAME/$NAME"_exec" $NUM $CONFIG_DIR $LOG_DIR || exit 1 &
else
echo "process $NAME-$NUM exist!"
fi
done
ps -x |grep _exec |grep server