forked from LibrePhotos/librephotos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·33 lines (25 loc) · 1.37 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
#! /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
/miniconda/bin/python image_similarity/main.py 2>&1 | tee logs/gunicorn_image_similarity.log &
/miniconda/bin/python manage.py showmigrations | tee logs/show_migrate.log
/miniconda/bin/python manage.py migrate | tee logs/command_migrate.log
/miniconda/bin/python manage.py showmigrations | tee logs/show_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 --worker-class=gevent --timeout 120 --bind 0.0.0.0:8001 --log-level=info ownphotos.wsgi 2>&1 | tee logs/gunicorn_django.log