-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcenter.sh
More file actions
executable file
·89 lines (76 loc) · 1.41 KB
/
center.sh
File metadata and controls
executable file
·89 lines (76 loc) · 1.41 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
#参数1: 命令
# start[默认] 启动
# stop 停止
CMD=$1
#参数2: 类型
# release[默认] 后台启动
# debug 前台启动
MODE=$2
TMP=$PATH
. /etc/init.d/functions
PATH=$TMP
CUR_PATH=$(dirname $(readlink -f $0))
PID_FILE=$CUR_PATH/center.pid
if [ -z "$3" ]; then
CONFIG=$CUR_PATH/common/config.center
else
CONFIG=$CUR_PATH/$3
fi
#后台启动
function back(){
echo -n $"Starting centerserver: "
$CUR_PATH/skynet-dist/skynet $CONFIG
if [ $? -eq 0 ]; then
success && echo
else
failure && echo
fi
}
#前台启动
function view(){
debug_cfg=$CUR_PATH/common/debug_cfg.center
sed -e 's/^logger/--logger/' -e 's/daemon/--daemon/' $CONFIG > $debug_cfg
$CUR_PATH/skynet-dist/skynet $debug_cfg
}
function start(){
case "$MODE" in
release)
#sh sh/log_name.sh center
back
;;
debug)
view
;;
*)
echo "mode[$MODE] invalid param, please sure [release|debug]"
exit 2
esac
}
function stop(){
if [ ! -f $PID_FILE ] ;then
echo "have no centerserver"
exit 0
fi
pid=`cat $PID_FILE`
exist_pid=`pgrep skynet | grep $pid`
if [ -z "$exist_pid" ] ;then
echo "have no centerserver"
exit 0
else
echo -n $"$pid centerserver will killed"
killproc -p $PID_FILE
echo
fi
}
case "$CMD" in
start)
start
;;
stop)
stop
;;
*)
echo "$0 start release|debug [config] | $0 stop"
exit 2
esac