summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 01a3009470e..cf9d390f0cb 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