I am planning to package my flask app as a pex for self contained distribution, wondering how can I run the pex in Gunicorn ? or maybe packaging even gunicorn in the executable so when I run the pex, flask app runs in gunicorn . is that even possible ?
I assembled an example app showing how to package a Flask application with Pex and run the resulting pex-file with Gunicorn, see here: https://github.com/wolkenarchitekt/pex-flask-gunicorn-example
These are the essential commands to package and run the app:
python setup.py sdist
pex -vv -r requirements.txt -D . -o ./hello-service.pex
PEX_SCRIPT=gunicorn ./hello-service.pex hello_service.main:app -b :8000
As you can see, Gunicorn is even packaged within the pex-file.