-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathserver.sh
88 lines (68 loc) · 1.29 KB
/
server.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
pidFile="/var/qserver_pid";
pidDbFile="/var/db_server_pid";
function start(){
php ./src/Core/YcfHttpServer.php $pidFile;
printf $?
if [ $? == 0 ]; then
printf "\qserver start OK\r\n"
return 0
else
printf "\qserver start FAIL\r\n"
return 1
fi
}
function stop(){
$(ps aux | grep "$pidFile" |grep -v "grep "| awk '{print $2}' | xargs kill -9)
PROCESS_NUM2=$(ps aux | grep "$pidFile" |grep -v "grep "| awk '{print $2}' | wc -l )
if [ $PROCESS_NUM2 == 0 ]; then
printf "\qserver stop OK\r\n"
return 0
else
printf "\qserver stop FAIL\r\n"
return 1
fi
}
function startDB(){
php ./src/Core/YcfDBServer.php $pidDbFile
if [ $? == 0 ]; then
printf "\db_server start OK\r\n"
return 0
else
printf "\db_server start FAIL\r\n"
return 1
fi
}
function stopDB(){
$(ps aux | grep "$pidDbFile" |grep -v "grep "| awk '{print $2}' | xargs kill -9)
PROCESS_NUM2=$(ps aux | grep "$pidDbFile" |grep -v "grep "| awk '{print $2}' | wc -l )
if [ $PROCESS_NUM2 == 0 ]; then
printf "\db_server stop OK\r\n"
return 0
else
printf "\db_server stop FAIL\r\n"
return 1
fi
}
case $1 in
start )
start
;;
startDB )
startDB
;;
stop)
stop
;;
stopDB)
stopDB
;;
restart)
stop
sleep 1
start
;;
*)
start
;;
esac