From c48b9f2098d39c635ff58a3994bf2e7d5a77323b Mon Sep 17 00:00:00 2001 From: Colin Campbell Date: Thu, 1 May 2014 15:17:44 +0100 Subject: [PATCH] Bug 12169 Use pid file in sipserver shutdown Change sample SIPConfig to request server writes a pid file Use this pid in shutdown rather than the current open to error method. Have also added to the Config parameters to ensure that the sipserver runs as the correct user and sets its own session id. These are always useful but makes it easier for users to run up the sipserver as root at boot time similarly to apache, mysql etc Added to the sample config where to locate other server parameter documentation. Removed from the sample config the unedifying, unwanted and purely historical http example Signed-off-by: Martin Renvoize --- etc/SIPconfig.xml | 9 ++++++++- misc/bin/sip_shutdown.sh | 19 +++++-------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/etc/SIPconfig.xml b/etc/SIPconfig.xml index 4277004f00..f30fbf6f9c 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -5,6 +5,10 @@ @@ -121,4 +129,3 @@ in our case "ILS". 0 - diff --git a/misc/bin/sip_shutdown.sh b/misc/bin/sip_shutdown.sh index 07abbce3f1..3545df9c92 100755 --- a/misc/bin/sip_shutdown.sh +++ b/misc/bin/sip_shutdown.sh @@ -1,19 +1,10 @@ #!/bin/bash -. $HOME/.bash_profile +#Terminates the session leader Sipserver which should terminate the children +# The pidfile name is specified as a server parameter in the configuration +# file -# this is brittle: the primary server must have the lowest PPID -# this is brittle: ps behavior is very platform-specific, only tested on Debian Etch +PID_FILE=/var/run/sipserver.pid -target="SIPServer"; -PROCPID=$(ps x -o pid,ppid,args --sort ppid | grep "$target" | grep -v grep | head -1 | awk '{print $1}'); +kill `cat $PID_FILE` -if [ ! $PROCPID ] ; then - echo "No processes found for $target"; - exit; -fi - -echo "SIP Processes for this user ($USER):"; -ps x -o pid,ppid,args --sort ppid | grep "$target" | grep -v grep ; -echo "Killing process #$PROCPID"; -kill $PROCPID; -- 2.20.1