Mercurial > libervia-web
annotate 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 |
rev | line source |
---|---|
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
1 #!/bin/sh |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
2 |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
3 DEBUG="" |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
4 PYTHON="python2" |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
5 |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
6 kill_process() { |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
7 # $1 is the file containing the PID to kill, $2 is the process name |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
8 if [ -f $1 ]; then |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
9 PID=`cat $1` |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
10 if ps -p $PID > /dev/null; then |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
11 echo "Terminating $2... " |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
12 kill -INT $PID |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
13 else |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
14 echo "No running process of ID $PID... removing PID file" |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
15 rm -f $1 |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
16 fi |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
17 else |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
18 echo "$2 is probably not running (PID file doesn't exist)" |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
19 fi |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
20 } |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
21 |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
22 #We use python to parse config files |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
23 eval `"$PYTHON" << PYTHONEND |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
24 |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
25 from sat.core.constants import Const as C |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
26 from sat.memory.memory import fixLocalDir |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
27 from ConfigParser import SafeConfigParser |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
28 from os.path import expanduser, join |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
29 import sys |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
30 |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
31 fixLocalDir() # XXX: tmp update code, will be removed in the future |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
32 |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
33 config = SafeConfigParser(defaults=C.DEFAULT_CONFIG) |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
34 try: |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
35 config.read(C.CONFIG_FILES) |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
36 except: |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
37 print ("echo \"/!\\ Can't read main config ! Please check the syntax\";") |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
38 print ("exit 1") |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
39 sys.exit() |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
40 |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
41 env=[] |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
42 env.append("PID_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'pid_dir')),'')) |
417
2bd609d7dd65
server_side: use XDG recommended paths as the defaults
souliane <souliane@mailoo.org>
parents:
360
diff
changeset
|
43 env.append("LOG_DIR='%s'" % join(expanduser(config.get('DEFAULT', 'log_dir')),'')) |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
44 print ";".join(env) |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
45 PYTHONEND |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
46 ` |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
47 APP_NAME="Libervia" # FIXME: the import from Python needs libervia module to be in PYTHONPATH |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
48 APP_NAME_FILE="libervia" |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
49 PID_FILE="$PID_DIR$APP_NAME_FILE.pid" |
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
50 LOG_FILE="$LOG_DIR$APP_NAME_FILE.log" |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
51 |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
52 # if there is one argument which is "stop", then we kill Libervia |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
53 if [ $# -eq 1 ];then |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
54 if [ $1 = "stop" ];then |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
55 kill_process $PID_FILE "$APP_NAME" |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
56 exit 0 |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
57 fi |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
58 if [ $1 = "debug" ];then |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
59 echo "Launching $APP_NAME in debug mode" |
418
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
60 DEBUG="--debug" |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
61 fi |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
62 fi |
ec8775575886
misc: libervia stop would not kill all libervia instances anymore
souliane <souliane@mailoo.org>
parents:
417
diff
changeset
|
63 |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
64 DAEMON="n" |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
65 MAIN_OPTIONS="-${DAEMON}o" |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
434
diff
changeset
|
66 DATA_DIR=".." |
360
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
67 |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
68 #Don't change the next line |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
69 AUTO_OPTIONS="" |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
70 ADDITIONAL_OPTIONS="--pidfile $PID_FILE --logfile $LOG_FILE $AUTO_OPTIONS $DEBUG" |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
71 |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
72 log_dir=`dirname "$LOG_FILE"` |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
73 if [ ! -d $log_dir ] ; then |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
74 mkdir $log_dir |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
75 fi |
9834136b15ed
added setup.py for the installation with setuptools
souliane <souliane@mailoo.org>
parents:
diff
changeset
|
76 |
434
d64b415c58ca
server_side: fixes startup script (as it's done in sat)
souliane <souliane@mailoo.org>
parents:
418
diff
changeset
|
77 echo "Starting $APP_NAME..." |
449
981ed669d3b3
/!\ reorganize all the file hierarchy, move the code and launching script to src:
souliane <souliane@mailoo.org>
parents:
434
diff
changeset
|
78 twistd $MAIN_OPTIONS $ADDITIONAL_OPTIONS $APP_NAME_FILE -d $DATA_DIR |