summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaushik BV <kbudiger@redhat.com>2012-01-20 11:54:21 +0530
committerVijay Bellur <vijay@gluster.com>2012-02-03 08:16:16 -0800
commit9636f5b16c1847bc94d42ca6ac948c680bd55f2e (patch)
tree67e226fce5cf0ac1dd0800e00ad28b54449e1799
parent7d81a11e661654394e116af52f0cab3d400ee2cf (diff)
extras: create PID file for glusterd when started from init scripts
thanks to Jaroslav Pulchart (jaroslav.pulchart@centrum.cz) for the patch Change-Id: Id07bf50536c8638f790f06e6e5994f85555c3978 BUG: 771221 Signed-off-by: Kaushik BV <kbudiger@redhat.com> Reviewed-on: http://review.gluster.com/2668 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rwxr-xr-xextras/init.d/glusterd-Redhat.in32
1 files changed, 25 insertions, 7 deletions
diff --git a/extras/init.d/glusterd-Redhat.in b/extras/init.d/glusterd-Redhat.in
index 01a300947..cf9d390f0 100755
--- a/extras/init.d/glusterd-Redhat.in
+++ b/extras/init.d/glusterd-Redhat.in
@@ -8,28 +8,46 @@
. /etc/rc.d/init.d/functions
BASE=glusterd
+PIDFILE=/var/run/$BASE.pid
+PID=`test -f $PIDFILE && cat $PIDFILE`
GLUSTERFSD=glusterfsd
GLUSTERFS=glusterfs
GLUSTERD_BIN=@prefix@/sbin/$BASE
-GLUSTERD_OPTS=""
+GLUSTERD_OPTS="--pid-file=$PIDFILE"
GLUSTERD="$GLUSTERD_BIN $GLUSTERD_OPTS"
RETVAL=0
# Start the service $BASE
start()
{
- echo -n $"Starting $BASE:"
- daemon $GLUSTERD
- RETVAL=$?
- echo
- [ $RETVAL -ne 0 ] && exit $RETVAL
+ pidofproc -p $PIDFILE $GLUSTERD_BIN &> /dev/null
+ status=$?
+ if [ $status -eq 0 ]; then
+ echo "glusterd service is already running with pid $PID"
+ exit 1
+ else
+ echo -n $"Starting $BASE:"
+ daemon $GLUSTERD
+ RETVAL=$?
+ echo
+ [ $RETVAL -ne 0 ] && exit $RETVAL
+ fi
+
}
# Stop the service $BASE
stop()
{
echo -n $"Stopping $BASE:"
- killproc $BASE
+ pidofproc -p $PIDFILE $GLUSTERD_BIN &> /dev/null
+ status=$?
+ if [ $status -eq 0 ]; then
+ killproc -p $PIDFILE $BASE
+ [ -w $PIDFILE ] && rm -f $PIDFILE
+ else
+ killproc $BASE
+ fi
+
echo
pidof -c -o %PPID -x $GLUSTERFSD &> /dev/null
[ $? -eq 0 ] && killproc $GLUSTERFSD &> /dev/null