comparison libervia_server/libervia.sh @ 418:ec8775575886

misc: libervia stop would not kill all libervia instances anymore
author souliane <souliane@mailoo.org>
date Sun, 23 Mar 2014 23:06:12 +0100
parents 2bd609d7dd65
children d64b415c58ca
comparison
equal deleted inserted replaced
417:2bd609d7dd65 418:ec8775575886
1 #!/bin/sh 1 #!/bin/sh
2 2
3 #if there is one argument which is "stop", then we kill libervia
4 DEBUG="" 3 DEBUG=""
5 if [ $# -eq 1 ];then 4 NAME="libervia"
6 if [ $1 = "stop" ];then 5 FULL_NAME="Libervia"
7 echo "Terminating Libervia" 6 PYTHON="python2"
8 pkill -f "twistd.*libervia" 7
9 exit 0 8 kill_process() {
9 # $1 is the file containing the PID to kill, $2 is the process name
10 if [ -f $1 ]; then
11 PID=`cat $1`
12 if ps -p $PID > /dev/null; then
13 echo "Terminating $2"
14 kill -INT $PID
15 else
16 echo "No running process of ID $PID... removing PID file"
17 rm -f $1
18 fi
19 else
20 echo "$2 is probably not running (PID file doesn't exist)"
10 fi 21 fi
11 if [ $1 = "debug" ];then 22 }
12 echo "Launching Libervia in debug mode"
13 DEBUG="--debug"
14 fi
15 fi
16
17 NAME='libervia'
18 PYTHON='python'
19 23
20 #We use python to parse config files 24 #We use python to parse config files
21 eval `"$PYTHON" << PYTHONEND 25 eval `"$PYTHON" << PYTHONEND
22 from sat.core.constants import Const 26 from sat.core.constants import Const
23 from ConfigParser import SafeConfigParser 27 from ConfigParser import SafeConfigParser
40 PYTHONEND 44 PYTHONEND
41 ` 45 `
42 46
43 PID_FILE="$PID_DIR$NAME.pid" 47 PID_FILE="$PID_DIR$NAME.pid"
44 LOG_FILE="$LOG_DIR$NAME.log" 48 LOG_FILE="$LOG_DIR$NAME.log"
49
50 # if there is one argument which is "stop", then we kill Libervia
51 if [ $# -eq 1 ];then
52 if [ $1 = "stop" ];then
53 kill_process $PID_FILE "$FULL_NAME"
54 exit 0
55 fi
56 if [ $1 = "debug" ];then
57 echo "Launching $FULL_NAME in debug mode"
58 DEBUG="--debug"
59 fi
60 fi
61
45 DAEMON="n" 62 DAEMON="n"
46 MAIN_OPTIONS="-${DAEMON}o" 63 MAIN_OPTIONS="-${DAEMON}o"
47 64
48 #Don't change the next line 65 #Don't change the next line
49 AUTO_OPTIONS="" 66 AUTO_OPTIONS=""
52 log_dir=`dirname "$LOG_FILE"` 69 log_dir=`dirname "$LOG_FILE"`
53 if [ ! -d $log_dir ] ; then 70 if [ ! -d $log_dir ] ; then
54 mkdir $log_dir 71 mkdir $log_dir
55 fi 72 fi
56 73
57 echo "Starting Libervia..." 74 echo "Starting $FULL_NAME..."
58 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $NAME 75 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $NAME