Patchwork [BUG:2969] build : use pid file to kill nfs process

login
register
Submitter Lakshmipathi
Date 2011-06-07 09:17:11
Message ID <20110607091711.GA27181@shell.gluster.com>
Download mbox | patch
Permalink /patch/7395/
State Accepted
Headers show

Comments

Lakshmipathi - 2011-06-07 09:17:11
Signed-off-by: Lakshmipathi.G <lakshmipathi@gluster.com>
---
 extras/init.d/glusterd-Redhat.in |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
Pavan - 2011-06-08 09:26:37
On Tuesday 07 June 2011 02:47 PM, Lakshmipathi wrote:
>
>
> Signed-off-by: Lakshmipathi.G<lakshmipathi@gluster.com>
> ---
>   extras/init.d/glusterd-Redhat.in |   13 +++++++++++--
>   1 files changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/extras/init.d/glusterd-Redhat.in b/extras/init.d/glusterd-Redhat.in
> index 0c39ff1..6e1260e 100755
> --- a/extras/init.d/glusterd-Redhat.in
> +++ b/extras/init.d/glusterd-Redhat.in
> @@ -34,8 +34,17 @@ stop()
>          pidof -c -o %PPID -x $GLUSTERFSD&>  /dev/null
>          [ $? -eq 0 ]&&   killproc $GLUSTERFSD&>  /dev/null
>
> -       pidof -c -o %PPID -x $GLUSTERFS&>  /dev/null
> -       [ $? -eq 0 ]&&   killproc $GLUSTERFS&>  /dev/null
> +       #pidof -c -o %PPID -x $GLUSTERFS&>  /dev/null
> +       #[ $? -eq 0 ]&&   killproc $GLUSTERFS&>  /dev/null

Is it necessary to retain the commented code above?

> +
> +       if [ -f /etc/glusterd/nfs/run/nfs.pid ] ;then
> +       pid=`cat /etc/glusterd/nfs/run/nfs.pid`;
> +       cmd=`ps -p $pid -o comm=`
> +
> +       if [ $cmd == "glusterfs" ]; then

"procname" is probably a better name for the variable. "cmd" makes it 
look like you are storing a command in that variable for later 
execution, but that clearly is not intent here.

> +       kill `cat /etc/glusterd/nfs/run/nfs.pid`

You already have the pid in $pid above. Any reason you get the pid from 
the file again?

Pavan

> +       fi
> +       fi
>   }
>
>
Lakshmipathi - 2011-06-08 09:47:46
Okay.I'll remove those commented out lines and change the variable name. 

>You already have the pid in $pid above. Any reason you get the pid from
the file again?
That lines wasn't changed from previous patch which doesn't use $pid.Will change this. 


--
----
Cheers,
Lakshmipathi.G
FOSS Programmer.

Patch

diff --git a/extras/init.d/glusterd-Redhat.in b/extras/init.d/glusterd-Redhat.in
index 0c39ff1..6e1260e 100755
--- a/extras/init.d/glusterd-Redhat.in
+++ b/extras/init.d/glusterd-Redhat.in
@@ -34,8 +34,17 @@  stop()
        pidof -c -o %PPID -x $GLUSTERFSD &> /dev/null
        [ $? -eq 0 ] &&  killproc $GLUSTERFSD &> /dev/null
 
-       pidof -c -o %PPID -x $GLUSTERFS &> /dev/null
-       [ $? -eq 0 ] &&  killproc $GLUSTERFS &> /dev/null
+       #pidof -c -o %PPID -x $GLUSTERFS &> /dev/null
+       #[ $? -eq 0 ] &&  killproc $GLUSTERFS &> /dev/null
+       
+       if [ -f /etc/glusterd/nfs/run/nfs.pid ] ;then
+       pid=`cat /etc/glusterd/nfs/run/nfs.pid`;
+       cmd=`ps -p $pid -o comm=`
+
+       if [ $cmd == "glusterfs" ]; then
+       kill `cat /etc/glusterd/nfs/run/nfs.pid` 
+       fi
+       fi 
 }