comparison src/libervia.sh @ 449:981ed669d3b3

/!\ reorganize all the file hierarchy, move the code and launching script to src: - browser_side --> src/browser - public --> src/browser_side/public - libervia.py --> src/browser/libervia_main.py - libervia_server --> src/server - libervia_server/libervia.sh --> src/libervia.sh - twisted --> src/twisted - new module src/common - split constants.py in 3 files: - src/common/constants.py - src/browser/constants.py - src/server/constants.py - output --> html (generated by pyjsbuild during the installation) - new option/parameter "data_dir" (-d) to indicates the directory containing html and server_css - setup.py installs libervia to the following paths: - src/common --> <LIB>/libervia/common - src/server --> <LIB>/libervia/server - src/twisted --> <LIB>/twisted - html --> <SHARE>/libervia/html - server_side --> <SHARE>libervia/server_side - LIBERVIA_INSTALL environment variable takes 2 new options with prompt confirmation: - clean: remove previous installation directories - purge: remove building and previous installation directories You may need to update your sat.conf and/or launching script to update the following options/parameters: - ssl_certificate - data_dir
author souliane <souliane@mailoo.org>
date Tue, 20 May 2014 06:41:16 +0200
parents libervia_server/libervia.sh@d64b415c58ca
children 750db9ff8525
comparison
equal deleted inserted replaced
448:14c35f7f1ef5 449:981ed669d3b3
1 #!/bin/sh
2
3 DEBUG=""
4 PYTHON="python2"
5
6 kill_process() {
7 # $1 is the file containing the PID to kill, $2 is the process name
8 if [ -f $1 ]; then
9 PID=`cat $1`
10 if ps -p $PID > /dev/null; then
11 echo "Terminating $2... "
12 kill -INT $PID
13 else
14 echo "No running process of ID $PID... removing PID file"
15 rm -f $1
16 fi
17 else
18 echo "$2 is probably not running (PID file doesn't exist)"
19 fi
20 }
21
22 #We use python to parse config files
23 eval `"$PYTHON" << PYTHONEND
24
25 from sat.core.constants import Const as C
26 from sat.memory.memory import fixLocalDir
27 from ConfigParser import SafeConfigParser
28 from os.path import expanduser, join
29 import sys
30
31 fixLocalDir() # XXX: tmp update code, will be removed in the future
32
33 config = SafeConfigParser(defaults=C.DEFAULT_CONFIG)
34 try:
35 config.read(C.CONFIG_FILES)
36 except:
37 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";")
38 print ("exit 1")
39 sys.exit()
40
41 env=[]
42 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),''))
43 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),''))
44 print ";".join(env)
45 PYTHONEND
46 `
47 APP_NAME="Libervia" # FIXME: the import from Python needs libervia module to be in PYTHONPATH
48 APP_NAME_FILE="libervia"
49 PID_FILE="$PID_DIR$APP_NAME_FILE.pid"
50 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log"
51
52 # if there is one argument which is "stop", then we kill Libervia
53 if [ $# -eq 1 ];then
54 if [ $1 = "stop" ];then
55 kill_process $PID_FILE "$APP_NAME"
56 exit 0
57 fi
58 if [ $1 = "debug" ];then
59 echo "Launching $APP_NAME in debug mode"
60 DEBUG="--debug"
61 fi
62 fi
63
64 DAEMON="n"
65 MAIN_OPTIONS="-${DAEMON}o"
66 DATA_DIR=".."
67
68 #Don't change the next line
69 AUTO_OPTIONS=""
70 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG"
71
72 log_dir=`dirname "$LOG_FILE"`
73 if [ ! -d $log_dir ] ; then
74 mkdir $log_dir
75 fi
76
77 echo "Starting $APP_NAME..."
78 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE -d $DATA_DIR