You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ability to provide an app.sh file makes things easier when wishing to run an alternate WSGI server such as uWSGI or Waitress where there may not be a way to start it up by importing a Python module and executing some API.
Right now you would have to do the following.
1 - Create a wsgi.py file with your WSGI application.
2 - Create an app.py file containing:
import os
os.execl('/opt/app-root/src/app.sh', 'uwsgi')
The reason for using the app.sh in this case is so that PATH searching for uwsgi program can be relied on. If you try and launch uwsgi from app.py, because os.exec calls require fill path, you have to either hardwire the path, the location of which would change if a switch is made to a Python virtual environment rather than per user site-packages, or you have to add a Python function to search PATH yourself.
Far simpler to add support for app.sh. So something like the following, which would go before existing check and execution of app.py.
APP_SCRIPT="${APP_SCRIPT:-app.sh}"
if [[ -x "$APP_SCRIPT" ]]; then
echo "---> Running application from script ($APP_SCRIPT) ..."
exec "$APP_SCRIPT"
fi
In general, easier to use shell script rather than Python code to do special stuff prior to executing command line based server.
The text was updated successfully, but these errors were encountered:
First raised as comment against separate issue:
but breaking out as independent issue.
The ability to provide an
app.sh
file makes things easier when wishing to run an alternate WSGI server such as uWSGI or Waitress where there may not be a way to start it up by importing a Python module and executing some API.Right now you would have to do the following.
1 - Create a
wsgi.py
file with your WSGI application.2 - Create an
app.py
file containing:3 - Create an
app.sh
file containing:The reason for using the
app.sh
in this case is so thatPATH
searching foruwsgi
program can be relied on. If you try and launchuwsgi
fromapp.py
, becauseos.exec
calls require fill path, you have to either hardwire the path, the location of which would change if a switch is made to a Python virtual environment rather than per usersite-packages
, or you have to add a Python function to searchPATH
yourself.Far simpler to add support for
app.sh
. So something like the following, which would go before existing check and execution ofapp.py
.In general, easier to use shell script rather than Python code to do special stuff prior to executing command line based server.
The text was updated successfully, but these errors were encountered: