Blame SOURCES/mysql-wait-stop.sh

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