From 6634a3e9a54821f5d32b8ed16ca261f69c7b20a2 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 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 --- 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 1e5c2314a2..12573fd1af 100644 --- a/etc/SIPconfig.xml +++ b/etc/SIPconfig.xml @@ -5,6 +5,10 @@ @@ -114,4 +122,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