changeset 434:d64b415c58ca

server_side: fixes startup script (as it's done in sat)
author souliane <souliane@mailoo.org>
date Thu, 01 May 2014 11:34:36 +0200
parents bbdbee25123a
children e63fc04efef7
files libervia_server/libervia.sh
diffstat 1 files changed, 16 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/libervia_server/libervia.sh	Thu May 01 11:29:09 2014 +0200
+++ b/libervia_server/libervia.sh	Thu May 01 11:34:36 2014 +0200
@@ -1,8 +1,6 @@
 #!/bin/sh
 
 DEBUG=""
-NAME="libervia"
-FULL_NAME="Libervia"
 PYTHON="python2"
 
 kill_process() {
@@ -10,7 +8,7 @@
     if [ -f $1 ]; then
         PID=`cat $1`
         if ps -p $PID > /dev/null; then
-            echo "Terminating $2"
+            echo "Terminating $2... "
             kill -INT $PID
         else
             echo "No running process of ID $PID... removing PID file"
@@ -23,14 +21,18 @@
 
 #We use python to parse config files
 eval `"$PYTHON" << PYTHONEND
-from sat.core.constants import Const
+
+from sat.core.constants import Const as C
+from sat.memory.memory import fixLocalDir
 from ConfigParser import SafeConfigParser
 from os.path import expanduser, join
 import sys
 
-config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG)
+fixLocalDir()  # XXX: tmp update code, will be removed in the future
+
+config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
 try:
-    config.read(Const.CONFIG_FILES)
+    config.read(C.CONFIG_FILES)
 except:
     print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
     print ("exit 1")
@@ -39,22 +41,22 @@
 env=[]
 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
-
 print ";".join(env)
 PYTHONEND
 `
-
-PID_FILE="$PID_DIR$NAME.pid"
-LOG_FILE="$LOG_DIR$NAME.log"
+APP_NAME="Libervia"  # FIXME: the import from Python needs libervia module to be in PYTHONPATH
+APP_NAME_FILE="libervia"
+PID_FILE="$PID_DIR$APP_NAME_FILE.pid"
+LOG_FILE="$LOG_DIR$APP_NAME_FILE.log"
 
 # if there is one argument which is "stop", then we kill Libervia
 if [ $# -eq 1 ];then
     if [ $1 = "stop" ];then
-        kill_process $PID_FILE "$FULL_NAME"
+        kill_process $PID_FILE "$APP_NAME"
         exit 0
     fi
     if [ $1 = "debug" ];then
-        echo "Launching $FULL_NAME in debug mode"
+        echo "Launching $APP_NAME in debug mode"
         DEBUG="--debug"
     fi
 fi
@@ -71,5 +73,5 @@
     mkdir $log_dir
 fi
 
-echo "Starting $FULL_NAME..."
-twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $NAME
+echo "Starting $APP_NAME..."
+twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE