150 lines
3.3 KiB
Bash
150 lines
3.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# maxscale: The SkySQL MaxScale database proxy
|
|
#
|
|
# description: MaxScale provides database specific proxy functionality
|
|
#
|
|
# processname: maxscale
|
|
#
|
|
### BEGIN INIT INFO
|
|
# Provides: maxscale
|
|
# Required-Start: $syslog $local_fs
|
|
# Required-Stop: $syslog $local_fs
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: The maxscale database proxy
|
|
# Description: MaxScale is a database proxy server that can be used to front end
|
|
# database clusters offering different routing, filtering and protocol choices
|
|
### END INIT INFO
|
|
|
|
export MAXSCALE_BASEDIR=/servers/maxscale-1.1.0
|
|
export MAXSCALE_BIN=$MAXSCALE_BASEDIR/bin
|
|
export MAXSCALE_HOME=$MAXSCALE_BASEDIR/MaxScale
|
|
export MAXSCALE_PIDFILE=$MAXSCALE_HOME/log/maxscale.pid
|
|
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MAXSCALE_BASEDIR/lib
|
|
|
|
# Sanity checks.
|
|
[ -x $MAXSCALE_BIN/maxscale ] || exit 7
|
|
|
|
# Source function library.
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
# so we can rearrange this easily
|
|
processname=maxscale
|
|
servicename=maxscale
|
|
|
|
RETVAL=0
|
|
|
|
start() {
|
|
echo `date` "Try to start" >> /tmp/maxscale.log
|
|
echo -n $"Starting MaxScale: "
|
|
|
|
#if [ -x $MAXSCALE_BIN/maxscale ] ; then
|
|
# $MAXSCALE_BIN/maxscale >& /dev/null
|
|
#fi
|
|
|
|
daemon --pidfile $MAXSCALE_PIDFILE $MAXSCALE_BIN/maxscale >& /dev/null
|
|
|
|
echo `date` "Started" >> /tmp/maxscale.log
|
|
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
|
|
|
echo
|
|
|
|
if [ $RETVAL -ne 0 ]; then
|
|
return 0;
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
startcheck() {
|
|
status -p $MAXSCALE_PIDFILE 'MaxScale'
|
|
RETVAL=$?
|
|
#if running status is 0, so return 1 here to the caller
|
|
if [ $RETVAL -eq 0 ]; then
|
|
# echo " return 1 forced, running"
|
|
return 1
|
|
fi
|
|
#echo " return 1 for not running"
|
|
return 0
|
|
}
|
|
|
|
stop() {
|
|
echo `date` "Try to stop" >> /tmp/maxscale.log
|
|
echo -n $"Stopping MaxScale: "
|
|
|
|
killproc -p $MAXSCALE_PIDFILE
|
|
RETVAL=$?
|
|
|
|
echo
|
|
|
|
if [ $RETVAL -eq 0 ]; then
|
|
rm -f /var/lock/subsys/$servicename
|
|
echo `date` "Stopped with subsys removed " >> /tmp/maxscale.log
|
|
return 0
|
|
else
|
|
echo `date` "Stopped without subsys removed " >> /tmp/maxscale.log
|
|
return 0;
|
|
fi
|
|
}
|
|
|
|
reload() {
|
|
echo -n $"Reloading MaxScale: "
|
|
|
|
killproc $servicename -HUP
|
|
RETVAL=$?
|
|
echo
|
|
}
|
|
|
|
# See how we were called.
|
|
case "$1" in
|
|
start)
|
|
#echo `date` "Check before start " >> /tmp/maxscale.log
|
|
#startcheck -p $MAXSCALE_PIDFILE 'MaxScale'
|
|
#RETVAL=$?
|
|
#echo -n "retval of startcheck is "
|
|
#echo $RETVAL
|
|
#if [ $RETVAL -eq 1 ]; then
|
|
# echo "MaxScale is running, $RETVAL"
|
|
# echo `date` "MaxScale runs, start skipped " >> /tmp/maxscale.log
|
|
# exit 0
|
|
#fi
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
status)
|
|
echo -n $"Checking MaxScale status: "
|
|
status -p $MAXSCALE_PIDFILE 'MaxScale'
|
|
RETVAL=$?
|
|
echo `date` ">>MaxScale true status is $RETVAL, !=0 -> 3, pidfile $MAXSCALE_PIDFILE" >> /tmp/maxscale.log
|
|
if [ $RETVAL -eq 1 ]; then
|
|
exit 3
|
|
fi
|
|
if [ $RETVAL -ne 0 ]; then
|
|
exit 3
|
|
fi
|
|
exit $RETVAL
|
|
;;
|
|
restart)
|
|
stop
|
|
start
|
|
;;
|
|
condrestart)
|
|
if [ -f /var/lock/subsys/$servicename ]; then
|
|
stop
|
|
start
|
|
fi
|
|
;;
|
|
reload)
|
|
reload
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
|
|
;;
|
|
esac
|
|
exit $RETVAL
|