forked from cloudfoundry/galera-init
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysql_daemon.sh
executable file
·55 lines (44 loc) · 1.53 KB
/
mysql_daemon.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
#!/bin/bash
set -e
mode=$1
STANDALONE_PID_FILE=/tmp/tmp-mysql.pid
case "$mode" in
'start')
echo "Starting MySQL"
/var/vcap/packages/mariadb/bin/mysqld_safe &
;;
'stop')
echo "Stopping the cluster"
/var/vcap/packages/mariadb/support-files/mysql.server stop
;;
# This was mostly taken from /var/vcap/packages/mariadb/support-files/mysql.server
# It cannot handle the fact the pid-file is in a different location than defined in my.cnf
# We don't wait for the process to stop, because the waiting/polling takes places at a higher level.
'stop-stand-alone')
echo "Stopping the standalone node"
mysqld_pid=`cat "$STANDALONE_PID_FILE"`
if (kill -0 $mysqld_pid 2>/dev/null)
then
echo $echo_n "Shutting down node"
kill $mysqld_pid
else
echo "Server process #$mysqld_pid is not running!"
rm "$STANDALONE_PID_FILE"
fi
;;
'bootstrap')
# Bootstrap the cluster, start the first node
# that initiate the cluster
echo "Bootstrapping the cluster"
/var/vcap/packages/mariadb/bin/mysqld_safe --wsrep-new-cluster &
;;
'stand-alone')
echo "Starting the node in stand-alone mode"
/var/vcap/packages/mariadb/bin/mysqld_safe --wsrep-on=OFF --wsrep-desync=ON --wsrep-OSU-method=RSU --wsrep-provider='none' --pid-file=$STANDALONE_PID_FILE &
;;
'status')
echo "Getting status of mysql process (exit 0 == running)"
/var/vcap/packages/mariadb/support-files/mysql.server status
;;
esac
exit 0