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 <martin.renvoize@ptfs-europe.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Colin Campbell 2014-05-01 15:17:44 +01:00 committed by Jonathan Druart
parent 4c79fe761b
commit d94d81fdf7
2 changed files with 13 additions and 15 deletions

View file

@ -5,6 +5,10 @@
<!--
Set Net::Server::PreFork runtime parameters
syslog_ident will identify SIP2 Koha server entries in syslog
See documentation for Net::Server
user and group select what user the service should run as
if started as root (e.g. in server startup ) the server will switch to
this user after binding to the socket it is listening on
For OpenSolaris, add: syslog_logsock=stream
-->
<server-params
@ -13,6 +17,10 @@
log_file='Sys::Syslog'
syslog_ident='koha_sip'
syslog_facility='local6'
setsid="1"
user='koha'
group='koha'
pid_file='/var/run/sipserver.pid'
/>
<listeners>
@ -121,4 +129,3 @@ in our case "ILS".
<AllFinesNeedOverride>0</AllFinesNeedOverride>
</syspref_overrides>
</acsconfig>

View file

@ -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;