Skip to content

Commit

Permalink
feat: clean up entrypoint. add loud fail to entrypoint.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhiiva committed Nov 12, 2021
1 parent cf21a03 commit 5d9fb2e
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions scripts/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/bin/bash

# Get the r_flag from the options.
while getopts ':r' flag; do
case ${flag} in
r)
get_options_r_flag=0
;;
esac
done
# Cause the script to fail loudly when it fails.
# see: (http://redsymbol.net/articles/unofficial-bash-strict-mode/)
set -euo pipefail

# Set the MySQL Command
MYSQL_COMMAND="mysql --host=$DB_HOST --port=$DB_PORT --user=$AGAGD_USER --password=$MYSQL_PASSWORD"
Expand All @@ -33,21 +28,6 @@ function wait_for_db() {

wait_for_db

# Start the server by default without py-autoload.
# If the r argument is supplied as in development,
# autoreload the server on py file changes.
function start_server() {
r_flag=${get_options_r_flag:-1}

if [ $r_flag == 0 ];
then
python manage.py runserver 0.0.0.0:8000
elif [ $r_flag == 1 ];
then
gunicorn -b 0.0.0.0:8000 agagd.wsgi
fi
}

if $LOAD_FIXTURES == "true"; then
python make_fake_fixtures.py 1000 1000 1000 > /tmp/fake_agagd_data.json
python manage.py loaddata /tmp/fake_agagd_data.json
Expand All @@ -58,4 +38,5 @@ fi
# other assets shown.
python manage.py collectstatic --noinput

start_server
# Allow the commands to be passed into Entrypoint.
exec "$@"

0 comments on commit 5d9fb2e

Please sign in to comment.