Blame SOURCES/mysql-wait-stop.sh

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