This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-my-data/docker/entrypoint.sh

76 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -e
echo -n "Starting up at "
date -Iseconds
if [ ! -e /etc/nginx/ssl/dhparams.pem ]; then
# We don't generate it automatically, because it should be mounted from
# the Docker host and generated only once, rather than every time a new
# container is created.
echo "/etc/nginx/ssl/dhparams.pem missing, generate with:"
echo
echo " openssl dhparam -out /etc/nginx/ssl/dhparams.pem 4096"
echo
echo "GENERATING TEMPORARY INSECURE FILE"
openssl dhparam -out /etc/nginx/ssl/dhparams.pem 512
fi
# Do this before we start Postgres so we shut that down
# even when nginx doesn't want to start.
function shutdown {
echo "Shutting down"
set +e
nginx -s stop
[ -e $ELASTIC_PID ] && kill $(<$ELASTIC_PID)
pg_ctlcluster 10 main stop
}
trap shutdown EXIT
# Configure and start Postgres.
if [ ! -e $PGDATA ]; then
echo "$PGDATA does not exist, initialising database"
. /create_db.sh
else
echo "Starting postgresql"
pg_ctlcluster 10 main start
fi
mkdir -p /var/log/{uwsgi,nginx,postgresql}/
echo "Starting ElasticSearch"
su elastic -c "/opt/elasticsearch/bin/elasticsearch --daemonize --pidfile $ELASTIC_PID"
echo "Running migrations"
cd /var/www/mydata
pipenv run python3 manage.py migrate
cd /var/www/opendata
pipenv run python3 manage.py migrate
echo "Starting uWSGI"
uwsgi /etc/uwsgi/apps-enabled/mydata.ini
uwsgi /etc/uwsgi/apps-enabled/opendata.ini
echo "Starting nginx"
nginx # -g 'daemon off;'
echo "Waiting for stuff"
set +e
tail -f /dev/null &
KILLPID=$!
function finish {
echo "Finishing Docker image"
set -x
kill $KILLPID
}
trap finish QUIT
trap finish TERM
trap finish INT
wait
echo "Done waiting, shutting down some stuff cleanly"