Blame SOURCES/mysql-wait-stop.sh

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