-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlaunch-stack.sh
executable file
·70 lines (57 loc) · 1.96 KB
/
launch-stack.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
63
64
65
66
67
68
69
70
#!/bin/bash
# Exit conditions...
# -e exits on error,
# -o (for option) pipefail exits on command pipe failures
set -eo pipefail
echo "Running migrations..."
cd /code
python manage.py migrate
echo "Loading fixtures..."
python manage.py loaddata tagcategories.json
echo "Running collectstatic..."
python manage.py collectstatic --noinput -v 0
echo "Creating superuser..."
# Automatically create the superuser...
script="
from django.contrib.auth.models import User
username = '$WEB_DJANGO_SUPERUSER_NAME'
password = '$WEB_DJANGO_SUPERUSER_PASSWORD'
email = '$WEB_DJANGO_SUPERUSER_EMAIL'
if not username or not password:
username = 'admin'
password = 'UNSECURED'
if User.objects.filter(username=username).count()==0:
User.objects.create_superuser(username, email, password)
print('Superuser created.')
else:
print('Superuser creation skipped.')
"
printf "$script" | python manage.py shell
echo "Preparing logging..."
touch /srv/logs/gunicorn.log
touch /srv/logs/access.log
touch /code/logs/logfile.log
CONCURRENCY=${STACK_CONCURRENCY:-4}
echo "Starting Gunicorn (CONCURRENCY=${CONCURRENCY})..."
gunicorn fragalysis.wsgi:application \
--daemon \
--name fragalysis \
--bind unix:django_app.sock \
--timeout 3000 \
--workers ${CONCURRENCY} \
--log-level=debug \
--log-file=/srv/logs/gunicorn.log \
--access-logfile=/srv/logs/access.log
# added as a fix to #1215, mixing http and https requests to enable
# local development with http. Need to set the env variable in compose
# file or .env.
# NB! this is probably a workaround for some other issue we haven't
# discovered yet. It suddenly broke but right now seems to work in
# firefox. Hopefully won't be necessary soon
echo proxy_set_header X-Forwarded-Proto "${PROXY_FORWARDED_PROTO_HEADER:-https};" >> /etc/nginx/frag_proxy_params
echo "Testing nginx config..."
nginx -tq
echo "Launching service health check queries"
python manage.py start_service_queries
echo "Running nginx..."
nginx