use*_*355 5 pex flask gunicorn
我打算将我的烧瓶应用程序打包为自包含分发的 pex,想知道如何在 Gunicorn 中运行 pex?或者甚至在可执行文件中打包 gunicorn ,所以当我运行 pex 时,flask 应用程序在 gunicorn 中运行。这甚至可能吗?
我组装了一个示例应用程序,展示如何使用 Pex 打包 Flask 应用程序并使用 Gunicorn 运行生成的 pex 文件,请参见此处:https : //github.com/wolkenarchitekt/pex-flask-gunicorn-example
这些是打包和运行应用程序的基本命令:
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
Run Code Online (Sandbox Code Playgroud)
如您所见,Gunicorn 甚至打包在 pex 文件中。