Blame SOURCES/mysql-wait-stop.sh

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