Blame SOURCES/mysql-wait-stop.sh

80384c
#!/bin/sh
80384c
80384c
source "`dirname ${BASH_SOURCE[0]}`/mysql-scripts-common"
80384c
80384c
# This script waits for mysqld to be properly stopped
80384c
# (which can be many seconds in some large load).
80384c
# Running this as ExecStopPost is useful so that starting which is done
80384c
# as part of restart doesn't see the former process still running.
80384c
80384c
# Wait for the server to properly end the main server
80384c
ret=0
80384c
TIMEOUT=60
80384c
SECONDS=0
80384c
80384c
if ! [ -f "$pidfile" ]; then
80384c
	exit 0
80384c
fi
80384c
80384c
MYSQLPID=`cat "$pidfile" 2>/dev/null`
80384c
if [ -z "$MYSQLPID" ] ; then
80384c
	exit 2
80384c
fi
80384c
80384c
while /bin/true; do
80384c
	# Check process still exists
80384c
	if ! [ -d "/proc/${MYSQLPID}" ] ; then
80384c
	    break
80384c
	fi
80384c
	if [ $SECONDS -gt $TIMEOUT ] ; then
80384c
	    ret=3
80384c
	    break
80384c
	fi
80384c
	sleep 1
80384c
done
80384c
80384c
exit $ret