2020-11-26 04:46:22 +00:00
|
|
|
#!/bin/sh
|
2018-02-21 04:37:10 +00:00
|
|
|
set -e
|
|
|
|
PYTHON=python3
|
|
|
|
|
2020-11-26 04:46:22 +00:00
|
|
|
# wait for mysql to be ready
|
|
|
|
LIMIT=30
|
|
|
|
i=0
|
|
|
|
until [ $i -ge $LIMIT ]
|
|
|
|
do
|
|
|
|
nc -z db 3306 && break
|
|
|
|
|
|
|
|
i=$(( i + 1 ))
|
|
|
|
|
|
|
|
echo "$i: Waiting for DB 1 second ..."
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $i -eq $LIMIT ]
|
|
|
|
then
|
|
|
|
echo "DB connection refused, terminating ..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# echo "determining bind location..."
|
|
|
|
# BIND_PORT=8000
|
|
|
|
# BIND_ADDR_=$(curl -w "\n" http://169.254.169.254/metadata/v1/interfaces/private/0/ipv4/address --connect-timeout 2 || printf "0.0.0.0")
|
|
|
|
# BIND_ADDR=$(echo $BIND_ADDR_ | xargs)
|
2018-02-21 04:37:10 +00:00
|
|
|
|
|
|
|
echo "starting EasyCTF..."
|
|
|
|
COMMAND=${1:-runserver}
|
|
|
|
ENVIRONMENT=${ENVIRONMENT:-production}
|
|
|
|
WORKERS=${WORKERS:-4}
|
2020-11-26 04:46:22 +00:00
|
|
|
flask db upgrade
|
|
|
|
|
2018-02-21 04:37:10 +00:00
|
|
|
if [ "$COMMAND" == "runserver" ]; then
|
2020-11-26 04:46:22 +00:00
|
|
|
flask run --host 0.0.0.0 --port 8000
|
|
|
|
# if [ "$ENVIRONMENT" == "development" ]; then
|
|
|
|
# $PYTHON manage.py runserver
|
|
|
|
# else
|
|
|
|
# exec gunicorn --bind="$BIND_ADDR:$BIND_PORT" -w $WORKERS 'easyctf:create_app()'
|
|
|
|
# fi
|
2018-02-21 04:37:10 +00:00
|
|
|
fi
|