-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
60 lines (51 loc) · 1.22 KB
/
entrypoint.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
#!/usr/bin/env bash
set -e
#export PYTHONPATH=$(pwd)
#echo "PYTHONPATH is $PYTHONPATH"
function migrate() {
echo "Migrating..."
python manage.py makemigrations
python manage.py migrate
}
function start() {
if [ "$USE_GUNICORN" == "true" ]
then
echo "Starting with gunicorn..."
gunicorn -c gunicorn_config.py server.wsgi:application --preload
else
echo "Starting with django..."
python manage.py runserver 0.0.0.0:8000
fi
}
function start_engine(){
python manage.py start_engine &
echo "engine started"
}
function main() {
cd django_common_task_system_server
echo "INIT is $INIT"
echo "SET_USER is $SET_USER"
export RUN_MAIN="false"
if [ "$INIT" == "true" ]
then
migrate
fi
if [ "$SET_USER" != "" -a "$SET_PASSWORD" != "" ]
then
python manage.py init -u $SET_USER -p $SET_PASSWORD --createsuperuser
elif [ "$SET_USER" != "" -a "$SET_PASSWORD" == "" ];
then
echo "You must set password for user $SET_USER"
exit 1
fi
python manage.py collectstatic --noinput
export RUN_MAIN="true"
if [ "$USE_GUNICORN" == "true" ]
then
echo "Set environment for gunicorn..."
export DJANGO_SERVER_ADDRESS=http://127.0.0.1:8000
fi
start_engine
start
}
main