-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-in-virtualenv.sh
executable file
·34 lines (25 loc) · 1.13 KB
/
run-in-virtualenv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
if [ ! -d env ] || [ $(grep VIRTUAL_ENV= env/bin/activate|cut -f2 -d'"') != "$PWD/env" ] ; then
rm -rf env
virtualenv -p python3 env
. env/bin/activate
pip install -r requirements.txt
fi
. env/bin/activate
if [ ! -f src/secrets.py ]; then
echo "You need to change the configuration in src/secrets.py (see src/secrets.template.py)" >&2
exit 1
fi
if [ "`grep USE_SSL src/secrets.py | grep True`" != "" ] && [ ! -f `grep SSL_KEY src/secrets.py | cut -f2 -d"'"` ]; then
echo "SSL certificate not found. Configure one in src/secrets.py. You can generate it for localhost with ./ssl/generate.sh" >&2
exit 1
fi
timestamp=`date '+%Y-%m-%d_%H:%M:%S'`
mkdir -p data/mongo data/pictures data/qrcodes data/export logs
# warn: remove disk-saving options in production (only keep --dbpath)
mongod --nojournal --nssize=1 --noprealloc --smallfiles --dbpath data/mongo --port `grep DB_URL src/secrets.py | cut -f2 -d"'" | awk -F: '{print $(NF)}'` > "logs/db_$timestamp.txt" 2>&1 &
# transpile js to ES5 supported by old browsers
./tools/babel.sh src -d static/
# run server
python -u src/server.py $* 2>&1 | tee "logs/server_$timestamp.txt"
kill %%