2021-09-05 17:10:14 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# startup script inside the container for tubearchivist
|
|
|
|
|
2021-10-28 09:17:47 +00:00
|
|
|
# check environment
|
2021-10-28 08:49:58 +00:00
|
|
|
if [[ -z "$ELASTIC_USER" ]]; then
|
|
|
|
export ELASTIC_USER=elastic
|
|
|
|
fi
|
|
|
|
|
2021-10-28 09:17:47 +00:00
|
|
|
ENV_VARS=("TA_USERNAME" "TA_PASSWORD" "ELASTIC_PASSWORD" "ELASTIC_USER")
|
|
|
|
for each in "${ENV_VARS[@]}"; do
|
|
|
|
if ! [[ -v $each ]]; then
|
|
|
|
echo "missing environment variable $each"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# wait for elasticsearch
|
2021-09-05 17:10:14 +00:00
|
|
|
counter=0
|
2021-10-28 08:49:58 +00:00
|
|
|
until curl -u "$ELASTIC_USER":"$ELASTIC_PASSWORD" "$ES_URL" -fs; do
|
2021-09-05 17:10:14 +00:00
|
|
|
echo "waiting for elastic search to start"
|
|
|
|
counter=$((counter+1))
|
|
|
|
if [[ $counter -eq 12 ]]; then
|
2021-10-25 06:23:54 +00:00
|
|
|
# fail after 2 min
|
2021-09-05 17:10:14 +00:00
|
|
|
echo "failed to connect to elastic search, exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-10-25 06:23:54 +00:00
|
|
|
sleep 10
|
2021-09-05 17:10:14 +00:00
|
|
|
done
|
|
|
|
|
2021-10-28 09:17:47 +00:00
|
|
|
# start python application
|
2021-10-21 12:33:27 +00:00
|
|
|
python manage.py makemigrations
|
2021-09-05 17:10:14 +00:00
|
|
|
python manage.py migrate
|
2021-10-25 12:28:05 +00:00
|
|
|
export DJANGO_SUPERUSER_PASSWORD=$TA_PASSWORD && \
|
|
|
|
python manage.py createsuperuser --noinput --name "$TA_USERNAME"
|
|
|
|
|
2021-09-16 14:59:36 +00:00
|
|
|
python manage.py collectstatic --noinput -c
|
2021-09-05 17:10:14 +00:00
|
|
|
nginx &
|
2021-09-13 15:18:03 +00:00
|
|
|
celery -A home.tasks worker --loglevel=INFO &
|
2021-12-08 09:15:25 +00:00
|
|
|
celery -A home beat --loglevel=INFO \
|
|
|
|
-s "${BEAT_SCHEDULE_PATH:-/cache/celerybeat-schedule}" &
|
2021-09-05 17:10:14 +00:00
|
|
|
uwsgi --ini uwsgi.ini
|