-
Notifications
You must be signed in to change notification settings - Fork 13
/
server.sh
64 lines (52 loc) · 2.11 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
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
echo -e "\033[35m ============================================================= \033[0m";
echo -e "\033[35m ********************** Githook ****************************** \033[0m";
echo -e "\033[35m Author: WenJun \033[0m";
echo -e "\033[35m Email: wenjun1055@gmail.com \033[0m";
echo '';
function ProxyManagement()
{
if [ "$1" != '' ]; then
selected=$1;
else
echo -e "\033[35m [Proxy] Githook Management please select: (1~6) \033[0m";
select selected in 'start' 'stop' 'restart' 'reload' 'kill9' 'exit'; do break; done;
echo '';
fi;
[ "$selected" == 'exit' ] && exit;
homework=`pwd`;
cd $homework;
if [ "$selected" == 'start' ]; then
/usr/bin/php server.php;
ps x | grep 'githook' | grep -v 'grep' >/dev/null && echo -e "\033[42;34m [OK] Githook Start \033[0m";
elif [ "$selected" == 'stop' ]; then
master_pid=`cat ./tmp/swoole.pid`;
kill -15 $master_pid && echo -e "\033[42;34m [OK] Worker Stop \033[0m";
sleep 1;
echo '';
kill -9 $master_pid && echo -e "\033[42;34m [OK] Master Stop \033[0m";
rm -rf ./tmp/swoole.pid;
elif [ "$selected" == 'reload' ]; then
master_pid=`cat ./tmp/swoole.pid`;
kill -USR1 $master_pid && echo -e "\033[42;34m [OK] Githook Reload \033[0m";
elif [ "$selected" == 'restart' ]; then
master_pid=`cat ./tmp/swoole.pid`;
kill -15 $master_pid && echo -e "\033[42;34m [OK] Worker Stop \033[0m";
sleep 1;
echo '';
kill -9 $master_pid && echo -e "\033[42;34m [OK] Master Stop \033[0m";
/usr/bin/php server.php;
echo '';
ps x | grep 'githook' | grep -v 'grep' >/dev/null && echo -e "\033[42;34m [OK] Githook Start \033[0m";
elif [ "$selected" == 'kill9' ]; then
ps -eaf |grep "githook" | grep -v "grep"| awk '{print $2}' | xargs kill -9;
echo -e "\033[42;34m [OK] Kill All Process \033[0m";
else
NginxManagement;
return;
fi;
}
ProxyManagement $1;
echo '';