-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_app.sh
62 lines (49 loc) · 1.16 KB
/
start_app.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
export $(cat ${DIR}/variables.env | xargs)
source /usr/local/bin/tc_variables.sh
venvdir="${venvDirectory}/${DJANGO_APP_NAME}_venv"
source "${venvdir}/bin/activate"
pip install -r "${DIR}/requirements.txt"
_int() {
for job in `jobs -p`
do
kill -TERM "$job" 2>/dev/null
done
exit 130
}
_term() {
for job in `jobs -p`
do
kill -TERM "$job" 2>/dev/null
done
exit 0
}
trap _int SIGINT
trap _term SIGTERM
FAIL=0
export PYTHONPATH=${DIR}
python -m application.manage makemigrations
python -m application.manage migrate
mkdir -p "${DIR}/static"
mkdir -p "${DIR}/medias"
if [[ "$#" -gt 0 ]] && [[ "$1" == "loadexampledata" ]]
then
fileList=$(find "${DIR}/fixtures/" -name *.json -printf "%f")
for file in ${fileList}; do
python -m application.manage loaddata "${DIR}/fixtures/${file}"
done
fi
python -m application.manage runserver 0.0.0.0:${WEBSERVER_PORT} &
python -m application.asyncmsg.main &
for job in `jobs -p`
do
wait ${job} || let "FAIL+=1"
done
if [[ "$FAIL" == "0" ]];
then
exit 0
else
exit 1
fi