Patchwork [Open-FCoE] initd.fedora: Do not start fcoemon twice

login
register
mail settings
Submitter Bhanu Prakash Gollapudi
Date April 5, 2013, 6:30 p.m.
Message ID <1365186623-17526-1-git-send-email-bprakash@broadcom.com>
Download mbox | patch
Permalink /patch/31/
State Accepted
Headers show

Comments

Bhanu Prakash Gollapudi - April 5, 2013, 6:30 p.m.
After the fix in commit-id cf50e10170b301542c968da6cdc278fd41730820 PID
file no longer exists in /var/run. As a result on initd.fedora fails to
check if fcoemon was already started.  This patch fixes the issue by
using -p option to obtain the PID, and not relying on the PID_FILE to
check if fcoemon is already running

Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
---
 etc/initd/initd.fedora |   28 +++++++++++++++-------------
 1 files changed, 15 insertions(+), 13 deletions(-)

Patch

diff --git a/etc/initd/initd.fedora b/etc/initd/initd.fedora
index 128d587..f20ed24 100755
--- a/etc/initd/initd.fedora
+++ b/etc/initd/initd.fedora
@@ -30,7 +30,6 @@ 
 ### END INIT INFO
 
 CONFIG_DIR=/etc/fcoe
-PID_FILE="/var/run/fcoemon.pid"
 LOG_FILE="/var/log/fcoemon.log"
 LOCKFILE="/var/lock/subsys/fcoe"
 FCOEMON=/usr/sbin/fcoemon
@@ -68,23 +67,26 @@  start()
 {
 	echo -n $"Starting FCoE initiator service: "
 
-	modprobe -q libfc
-	modprobe -q sg
-	modprobe -q -a $SUPPORTED_DRIVERS
+	pid=$($FCOEADM -p 2> /dev/null)
+	if [ -z "$pid" ]; then
+		modprobe -q libfc
+		modprobe -q sg
+		modprobe -q -a $SUPPORTED_DRIVERS
 
-	daemon --pidfile ${PID_FILE} ${FCOEMON} ${FCOEMON_OPTS}
-
-	echo
-	touch ${LOCKFILE}
-
-	echo
+		daemon ${FCOEMON} ${FCOEMON_OPTS}
+		echo
+		touch ${LOCKFILE}
+		echo
+	else
+		echo "(already running)"
+	fi
 }
 
 stop()
 {
 	local force=$1
 
-	pid=$(pidof "$FCOEMON")
+	pid=$($FCOEADM -p 2> /dev/null)
 	if [ "$force" == "force" ]
 	then
 		action "Destroying any active fcoe interface/s"
@@ -96,7 +98,6 @@  stop()
 
 	action $"Stopping FCoE initiator service: "
 
-	rm -f ${PID_FILE}
 	rm -f ${LOCKFILE}
 }
 
@@ -105,7 +106,8 @@  status()
 	[ -f ${LOCKFILE} ] || { echo "$FCOEMON is stopped" ; return 3; }
 
 	status=0
-	echo "$FCOEMON is running, pid=`cat $PID_FILE`"
+	pid=$($FCOEADM -p 2> /dev/null)
+	echo "$FCOEMON is running, pid=$pid"
 
 	interfaces=`$FCOEADM -i 2>&1 | \
 		    awk '/Symbolic Name:/{print $6}' | \