Skip to contentSkip to conversation

cluster/rgmanager/src/resources apache.sh mysq ...

Cluster-devel [email protected] 1 participant 1 message Sep 29, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: mgrac at sourceware.org 2006-09-29 11:35:16

Modified files:
rgmanager/src/resources: apache.sh mysql.sh openldap.sh
postgres-8.sh samba.sh
rgmanager/src/resources/utils: config-utils.sh

Log message:
Test if PID file of the application points to running PID. If not then this PID file is deleted and application can start.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/apache.sh.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/mysql.sh.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/openldap.sh.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/postgres-8.sh.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/samba.sh.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/utils/config-utils.sh.diff?cvsroot=cluster&r1=1.3&r2=1.4

rgmanager/src/resources/apache.sh +2 -1
@@ -162,8 +162,9 @@
 	clog_service_start $CLOG_INIT	
 
 	create_pid_directory
+	check_pid_file "$APACHE_pid_file"
 
-	if [ -e "$APACHE_pid_file" ]; then
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$APACHE_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
rgmanager/src/resources/mysql.sh +2 -1
@@ -79,8 +79,9 @@
 	clog_service_start $CLOG_INIT
 
 	create_pid_directory
+	check_pid_file "$MYSQL_pid_file"
 
-	if [ -e "$MYSQL_pid_file" ]; then
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$MYSQL_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
rgmanager/src/resources/openldap.sh +2 -2
@@ -127,13 +127,13 @@
 	clog_service_start $CLOG_INIT
 
 	create_pid_directory
+	check_pid_file "$LDAP_pid_file"
 
-	if [ -e "$LDAP_pid_file" ]; then
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$LDAP_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
 	fi
-
 	clog_looking_for $CLOG_INIT "IP Addresses"
 
         ccs_fd=$(ccs_connect);
rgmanager/src/resources/postgres-8.sh +2 -1
@@ -120,8 +120,9 @@
 	clog_service_start $CLOG_INIT
 
 	create_pid_directory
+	check_pid_file "$PSQL_pid_file"
 
-	if [ -e "$PSQL_pid_file" ]; then
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$PSQL_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
rgmanager/src/resources/samba.sh +5 -2
@@ -110,14 +110,17 @@
 
 	create_pid_directory
 	mkdir -p "$SAMBA_pid_dir"
+	check_pid_file "$SAMBA_smbd_pid_file"
 
-	if [ -e "$SAMBA_smbd_pid_file" ]; then
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$SAMBA_smbd_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
 	fi
 
-	if [ -e "$SAMBA_nmbd_pid_file" ]; then
+	check_pid_file "$SAMBA_nmbd_pid_file"
+
+	if [ $? -ne 0 ]; then
 		clog_check_pid $CLOG_FAILED "$SAMBA_nmbd_pid_file"
 		clog_service_start $CLOG_FAILED
 		return $OCF_ERR_GENERIC
rgmanager/src/resources/utils/config-utils.sh +20 -0
@@ -252,4 +252,24 @@
 	fi
 
 	return 0;
+}
+
+check_pid_file() {
+	declare pid_file="$1"
+
+	if [ -z "$pid_file" ]; then
+		return 1;
+	fi
+
+	if [ ! -e "$pid_file" ]; then
+		return 0;
+	fi
+
+	if [ ! -d /proc/`cat "$pid_file"` ]; then	
+		rm "$pid_file"
+		ocf_log debug "PID File \"$pid_file\" Was Removed - PID Does Not Exist";
+		return 0;
+	fi
+
+	return 1;
 }
\ No newline at end of file