This repository has been archived by the owner on Aug 25, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
start.sh
executable file
·76 lines (61 loc) · 2.66 KB
/
start.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
71
72
73
74
75
76
#!/bin/sh
cd /srv/taiga/back
source .venv/bin/activate
INITIAL_SETUP_LOCK=/taiga-conf/.initial_setup.lock
if [ ! -f $INITIAL_SETUP_LOCK ]; then
touch $INITIAL_SETUP_LOCK
if [ "$TAIGA_SCHEME" == 'http' -a "$TAIGA_PORT" != '80' ] || [ "$TAIGA_SCHEME" == 'https' -a "$TAIGA_PORT" != '443' ]; then
TAIGA_PORT=":$TAIGA_PORT"
else
TAIGA_PORT=''
fi
TAIGA_SECRET_ESCAPED=$(echo "$TAIGA_SECRET" | sed 's/[&/\]/\\&/g')
POSTGRES_PASSWORD_ESCAPED=$(echo "$POSTGRES_PASSWORD" | sed 's/[&/\]/\\&/g')
RABBIT_PASSWORD_ESCAPED=$(echo "$RABBIT_PASSWORD" | sed 's/[&/\]/\\&/g')
sed -e 's/$TAIGA_HOST/'$TAIGA_HOST'/' \
-e 's/$TAIGA_PORT/'$TAIGA_PORT'/' \
-e 's/$TAIGA_SECRET/'$TAIGA_SECRET_ESCAPED'/' \
-e 's/$TAIGA_SCHEME/'$TAIGA_SCHEME'/' \
-e 's/$POSTGRES_HOST/'$POSTGRES_HOST'/' \
-e 's/$POSTGRES_DB/'$POSTGRES_DB'/' \
-e 's/$POSTGRES_USER/'$POSTGRES_USER'/' \
-e 's/$POSTGRES_PASSWORD/'$POSTGRES_PASSWORD_ESCAPED'/' \
-e 's/$RABBIT_HOST/'$RABBIT_HOST'/' \
-e 's/$RABBIT_PORT/'$RABBIT_PORT'/' \
-e 's/$RABBIT_USER/'$RABBIT_USER'/' \
-e 's/$RABBIT_PASSWORD/'$RABBIT_PASSWORD_ESCAPED'/' \
-e 's/$RABBIT_VHOST/'$RABBIT_VHOST'/' \
-i /tmp/taiga-conf/config.py
cp /tmp/taiga-conf/config.py /taiga-conf/
ln -sf /taiga-conf/config.py /srv/taiga/back/settings/config.py
ln -sf /taiga-media /srv/taiga/back/media
echo 'Waiting for database to become ready...'
python3 /waitfordb.py
echo 'Running initial setup...'
python3 manage.py migrate --noinput
python3 manage.py loaddata initial_user
python3 manage.py loaddata initial_project_templates
python3 manage.py compilemessages
python3 manage.py collectstatic --noinput
else
ln -sf /taiga-conf/config.py /srv/taiga/back/settings/config.py
ln -sf /taiga-media /srv/taiga/back/media
echo 'Waiting for database to become ready...'
python3 /waitfordb.py
echo 'Running database update...'
python3 manage.py migrate --noinput
python3 manage.py compilemessages
python3 manage.py collectstatic --noinput
echo 'Installing cron jobs...'
echo '*/5 * * * * cd /srv/taiga/back && /usr/bin/python3 manage.py send_notifications >> /var/log/cron 2>&1' > /etc/crontabs/root
fi
C_FORCE_ROOT=1 .venv/bin/celery -A taiga worker --concurrency 4 -l INFO &
CELERY_PID=$!
.venv/bin/gunicorn --workers 4 --timeout 60 -b 127.0.0.1:8000 taiga.wsgi > /dev/stdout 2> /dev/stderr &
TAIGA_PID=$!
mkdir /run/nginx
nginx -g 'daemon off;' &
NGINX_PID=$!
crond >> /var/log/crond 2>&1
trap 'kill -TERM $NGINX_PID; kill -TERM $TAIGA_PID; kill -TERM $CELERY_PID' SIGTERM
wait $NGINX_PID $TAIGA_PID $CELERY_PID