SOURCES (MYSQL_5_0): mysql.init - wait for pid, not blindly by time

glen glen at pld-linux.org
Tue May 15 09:45:12 CEST 2007


Author: glen                         Date: Tue May 15 07:45:12 2007 GMT
Module: SOURCES                       Tag: MYSQL_5_0
---- Log message:
- wait for pid, not blindly by time

---- Files affected:
SOURCES:
   mysql.init (1.105.4.1 -> 1.105.4.1.2.1) 

---- Diffs:

================================================================
Index: SOURCES/mysql.init
diff -u SOURCES/mysql.init:1.105.4.1 SOURCES/mysql.init:1.105.4.1.2.1
--- SOURCES/mysql.init:1.105.4.1	Fri Dec 22 21:20:57 2006
+++ SOURCES/mysql.init	Tue May 15 09:45:07 2007
@@ -244,14 +244,30 @@
 	busy
 	[ -z "$DEFAULT_SERVICE_RUN_NICE_LEVEL" ] && DEFAULT_SERVICE_RUN_NICE_LEVEL=0
 	rm -f "$MYSQL_PIDFILE"
-	TMPDIR=/tmp nice -n ${SERVICE_RUN_NICE_LEVEL:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} /usr/bin/setsid /usr/sbin/mysqld --defaults-file=$MYSQL_CONFIG --datadir=$MYSQL_DATA_DIR --pid-file=$MYSQL_PIDFILE $MYSQL_OPTIONS >> $MYSQL_ERRLOG 2>&1 &
-	sleep 0.2
+
+	TMPDIR=/tmp nice -n ${SERVICE_RUN_NICE_LEVEL:-$DEFAULT_SERVICE_RUN_NICE_LEVEL} \
+   		/usr/bin/setsid /usr/sbin/mysqld \
+			--defaults-file=$MYSQL_CONFIG \
+			--datadir=$MYSQL_DATA_DIR \
+			--pid-file=$MYSQL_PIDFILE $MYSQL_OPTIONS \
+		>> $MYSQL_ERRLOG 2>&1 &
+	pid=$!
+
+	sleep 0.1
 	mysqlstatus "$clusterdir" start
 	# it takes longer for mysqld to start and create pidfile if it has to recover innodb transactions
 	if [ "$MYSQL_STATUS" = "starting" ]; then
-		for nr in $(seq 1 $(($MYSQL_START_WAIT_TIME*10))); do
+		echo ""
+		show "Waiting for MySQL to start"
+		busy
+
+		# while the pid is running, mysql is starting up
+		# if the pidfile was created, it started up successfully
+		# if either case fails we break and report status
+		while true; do
+			[ -d /proc/$pid ] || break
 			[ -f "$MYSQL_PIDFILE" ] && break
-			sleep 0.1
+			sleep 0.2
 		done
 	fi
 
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/mysql.init?r1=1.105.4.1&r2=1.105.4.1.2.1&f=u



More information about the pld-cvs-commit mailing list