Blame SOURCES/mysql-wait-stop.sh

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