django-ex/.sti/bin/run

39 lines
775 B
Text
Raw Normal View History

2015-05-22 13:47:35 +02:00
#!/bin/bash
function is_gunicorn_installed() {
pip show gunicorn
}
# For SCL enablement
source .bashrc
set -e
2015-05-22 14:00:57 +02:00
# Support for Django
# Take shallowest manage.py script
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' -printf '%d\t%P\n' | sort -nk1 | cut -f2 | head -1)
if pip show -q django && [ -f "$MANAGE_FILE" ]; then
set -x
python $MANAGE_FILE migrate --noinput
set +x
fi
2015-05-22 13:47:35 +02:00
export APP_FILE=${APP_FILE:-"app.py"}
if [[ ! -v APP_MODULE && -f setup.py ]]; then
APP_MODULE=`python setup.py --name`":application"
fi
if is_gunicorn_installed && [[ -v APP_MODULE ]]; then
if [[ -v APP_CONFIG ]]; then
export CONFIG="--config ${APP_CONFIG}"
fi
exec gunicorn ${APP_MODULE} --bind=:8080 ${CONFIG}
fi
exec python -u ${APP_FILE}