forked from Qihoo360/Atlas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmysql-proxyd
More file actions
executable file
·88 lines (73 loc) · 1.52 KB
/
mysql-proxyd
File metadata and controls
executable file
·88 lines (73 loc) · 1.52 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/bash
name="MySQL-Proxy of $1"
proxydir=/usr/local/mysql-proxy
binfile="$proxydir/bin/mysql-proxy"
pidfile="$proxydir/log/$1.pid"
confile="$proxydir/conf/$1.cnf"
function start()
{
ps -ef | grep "mysql-proxy --defaults-file=.*$1.cnf" | grep -v grep >/dev/null 2>&1
if [ "$?" == "0" ]; then
echo "error: $name is running now"
exit 2
else
$binfile --defaults-file=$confile
if [ "$?" == "0" ]; then
echo "OK: $name is started"
else
echo "error: failed to start $name"
exit 2
fi
fi
}
function stop()
{
ps -ef | grep "mysql-proxy --defaults-file=.*$1.cnf" | grep -v grep >/dev/null 2>&1
if [ "$?" == "0" ]; then
ps -ef | grep "mysql-proxy --defaults-file=.*$1.cnf" | grep -v grep | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1
if [ "$?" == "0" ]; then
rm -f $pidfile
echo "OK: $name is stopped"
else
echo "error: failed to stop $name"
exit 3
fi
else
echo "error: $name is NOT running"
exit 3
fi
}
function restart()
{
stop $1
start $1
}
function status()
{
ps -ef | grep "mysql-proxy --defaults-file=.*$1.cnf" | grep -v grep >/dev/null 2>&1
if [ "$?" == "0" ]; then
ps -ef | grep "mysql-proxy --defaults-file=.*$1.cnf" | grep -v grep | awk '{print $2}' | while read proxy_pid; do
echo "$name is running ($proxy_pid)"
done
else
echo "$name is NOT running"
fi
}
case $2 in
"start")
start $1
;;
"stop")
stop $1
;;
"restart")
restart $1
;;
"status")
status $1
;;
*)
echo "Usage: $0 instance {start|stop|restart|status}"
exit 1
esac
exit 0