@@ -35,6 +35,11 @@ function get_default_web_concurrency() {
3535 echo $default
3636}
3737
38+ APP_HOME=$( readlink -f " ${APP_HOME:- .} " )
39+ # Change the working directory to APP_HOME
40+ PYTHONPATH=" $( pwd) ${PYTHONPATH: +: $PYTHONPATH } "
41+ cd " $APP_HOME "
42+
3843app_script_check=" ${APP_SCRIPT-} "
3944APP_SCRIPT=" ${APP_SCRIPT-app.sh} "
4045if [[ -f " $APP_SCRIPT " ]]; then
5661 test -n " $app_file_check " && (>&2 echo " ERROR: file '$app_file_check ' not found." ) && exit 1
5762fi
5863
59- APP_HOME=${APP_HOME:- .}
60- # Look for 'manage.py' in the directory specified by APP_HOME, or the current direcotry
61- manage_file=$APP_HOME /manage.py
64+ # Look for 'manage.py' in the current directory
65+ manage_file=./manage.py
6266
6367if should_migrate; then
6468 if [[ -f " $manage_file " ]]; then
@@ -71,14 +75,12 @@ if should_migrate; then
7175fi
7276
7377if is_gunicorn_installed; then
74- if [[ -z " $APP_MODULE " ]]; then
75- # Look only in the directory specified by APP_HOME, or the current directory
76- # replace all "/" with ".", remove leading "." and ".py" suffix
77- APP_MODULE=$( find $APP_HOME -maxdepth 1 -type f -name ' wsgi.py' | sed ' s:/:.:g;s:^\.\+::;s:\.py$::' )
78- fi
79-
80- if [[ -z " $APP_MODULE " && -f setup.py ]]; then
81- APP_MODULE=" $( python setup.py --name) "
78+ setup_py=$( find " $HOME " -maxdepth 2 -type f -name ' setup.py' -print -quit)
79+ # Look for wsgi module in the current directory
80+ if [[ -z " $APP_MODULE " && -f " ./wsgi.py" ]]; then
81+ APP_MODULE=wsgi
82+ elif [[ -z " $APP_MODULE " && -f " $setup_py " ]]; then
83+ APP_MODULE=" $( python " $setup_py " --name) "
8284 fi
8385
8486 if [[ " $APP_MODULE " ]]; then
0 commit comments