Blame SOURCES/mysql-wait-stop.sh

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