-
Notifications
You must be signed in to change notification settings - Fork 233
/
entrypoint.sh
executable file
·42 lines (26 loc) · 1.39 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
#! /bin/bash
export PYTHONUNBUFFERED=TRUE
mkdir -p /code/logs
cp /code/nginx.conf /etc/nginx/sites-enabled/default
sed -i -e 's/replaceme/'"$BACKEND_HOST"'/g' /etc/nginx/sites-enabled/default
# run nginx as root - see https://github.com/hooram/ownphotos/issues/78
sed -i -e 's/user www-data/user root/g' /etc/nginx/nginx.conf
service nginx restart
# source /venv/bin/activate
/miniconda/bin/pip install gevent
/miniconda/bin/python image_similarity/main.py 2>&1 | tee logs/gunicorn_image_similarity.log &
/miniconda/bin/python manage.py makemigrations api 2>&1 | tee logs/command_makemigrations.log
/miniconda/bin/python manage.py migrate 2>&1 | tee logs/command_migrate.log
/miniconda/bin/python manage.py build_similarity_index 2>&1 | tee logs/command_build_similarity_index.log
/miniconda/bin/python manage.py shell <<EOF
from api.models import User
if User.objects.filter(username="$ADMIN_USERNAME").exists():
admin_user = User.objects.get(username="$ADMIN_USERNAME")
admin_user.set_password("$ADMIN_PASSWORD")
admin_user.save()
else:
User.objects.create_superuser('$ADMIN_USERNAME', '$ADMIN_EMAIL', '$ADMIN_PASSWORD')
EOF
echo "Running backend server..."
/miniconda/bin/python manage.py rqworker default 2>&1 | tee logs/rqworker.log &
/miniconda/bin/gunicorn --workers=2 --worker-class=gevent --bind 0.0.0.0:8001 --log-level=info ownphotos.wsgi 2>&1 | tee logs/gunicorn_django.log