comparison src/sat.sh @ 1003:52ec79aa5bbe

memory: fixes the method fixLocalDir for pid_dir and log_dir to use local_dir as default
author souliane <souliane@mailoo.org>
date Wed, 30 Apr 2014 19:54:21 +0200
parents 3b30e9f83d88
children 7293233970ab
comparison
equal deleted inserted replaced
1002:291eb8216f6e 1003:52ec79aa5bbe
1 #!/bin/sh 1 #!/bin/sh
2 2
3 DEBUG="" 3 DEBUG=""
4 NAME="sat"
5 FULL_NAME="Salut à Toi"
6 PYTHON="python2" 4 PYTHON="python2"
7 5
8 kill_process() { 6 kill_process() {
9 # $1 is the file containing the PID to kill, $2 is the process name 7 # $1 is the file containing the PID to kill, $2 is the process name
10 if [ -f $1 ]; then 8 if [ -f $1 ]; then
21 fi 19 fi
22 } 20 }
23 21
24 #We use python to parse config files 22 #We use python to parse config files
25 eval `"$PYTHON" << PYTHONEND 23 eval `"$PYTHON" << PYTHONEND
26 from sat.core.constants import Const 24 from sat.core.constants import Const as C
25 from sat.memory.memory import fixLocalDir
27 from ConfigParser import SafeConfigParser 26 from ConfigParser import SafeConfigParser
28 from os.path import expanduser, join 27 from os.path import expanduser, join
29 import sys 28 import sys
30 29
31 config = SafeConfigParser(defaults=Const.DEFAULT_CONFIG) 30 fixLocalDir() # XXX: tmp update code, will be removed in the future
31
32 config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
32 try: 33 try:
33 config.read(Const.CONFIG_FILES) 34 config.read(C.CONFIG_FILES)
34 except: 35 except:
35 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") 36 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
36 print ("exit 1") 37 print ("exit 1")
37 sys.exit() 38 sys.exit()
38 39
39 env=[] 40 env=[]
40 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) 41 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
41 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) 42 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
42 43
44 env.append("APP_NAME_FILE='%s'" % C.APP_NAME_FILE)
43 print ";".join(env) 45 print ";".join(env)
44 PYTHONEND 46 PYTHONEND
45 ` 47 `
46 48 APP_NAME="Salut à Toi" # FIXME: the import from Python constants fails because of the à
47 PID_FILE="$PID_DIR$NAME.pid" 49 PID_FILE="$PID_DIR$APP_NAME_FILE.pid"
48 LOG_FILE="$LOG_DIR$NAME.log" 50 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log"
49 51
50 # if there is one argument which is "stop", then we kill SàT 52 # if there is one argument which is "stop", then we kill SàT
51 if [ $# -eq 1 ];then 53 if [ $# -eq 1 ];then
52 if [ $1 = "stop" ];then 54 if [ $1 = "stop" ];then
53 kill_process $PID_FILE "$FULL_NAME" 55 kill_process $PID_FILE "$APP_NAME"
54 exit 0 56 exit 0
55 fi 57 fi
56 if [ $1 = "debug" ];then 58 if [ $1 = "debug" ];then
57 echo "Launching $FULL_NAME in debug mode" 59 echo "Launching $APP_NAME in debug mode"
58 DEBUG="--debug" 60 DEBUG="--debug"
59 fi 61 fi
60 fi 62 fi
61 63
62 DAEMON="n" 64 DAEMON="n"
63 MAIN_OPTIONS="-${DAEMON}oy" 65 MAIN_OPTIONS="-${DAEMON}oy"
64 TAP_PATH="./" 66 TAP_PATH="./"
65 TAP_FILE="$NAME.tac" 67 TAP_FILE="$APP_NAME_FILE.tac"
66 68
67 #Don't change the next line 69 #Don't change the next line
68 AUTO_OPTIONS="" 70 AUTO_OPTIONS=""
69 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG" 71 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"
70 72