-
Notifications
You must be signed in to change notification settings - Fork 6
/
docker-entrypoint.sh
executable file
Β·56 lines (45 loc) Β· 1.32 KB
/
docker-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
#!/bin/bash
export DJANGO_SETTINGS_MODULE=${DJANGO_SETTINGS_MODULE:-pyconkr.settings}
# echo "Wait for starting database"
# while !</dev/tcp/db/5432; do sleep 1; done;
# sleep 10
echo "Collect static files"
python manage.py collectstatic --noinput
echo "Apply database migrations"
python manage.py migrate
echo "Create admin user"
CREATE_ADMIN_SOURCE="
from django.contrib.auth.models import User
from django.contrib.auth import get_user_model
UserModel = get_user_model()
# Create admin user
USERNAME='pyconkr'
EMAIL='[email protected]'
PASSWORD='${PYCONKR_ADMIN_PASSWORD}'
try:
UserModel.objects.get(username=USERNAME)
except UserModel.DoesNotExist:
User.objects.create_superuser(USERNAME, EMAIL, PASSWORD)
"
echo "${CREATE_ADMIN_SOURCE}" | python manage.py shell
echo "==== Starting cron ====="
python manage.py crontab show
python manage.py crontab add
python manage.py crontab show
service cron start
mkdir -p /logs
touch /logs/gunicorn.log
touch /logs/access.log
tail -n 0 -f /logs/*.log &
echo "==== Starting server ====="
gunicorn pyconkr.wsgi:application \
--bind=0.0.0.0:8000 \
--workers 13 \
--threads 256 \
--worker-connections=5000 \
--max-requests 10000 \
--max-requests-jitter 5 \
-k gevent \
--log-level=info \
--log-file=/logs/gunicorn.log \
--access-logfile=/logs/access.log