【发布时间】:2020-08-29 20:46:58
【问题描述】:
我的头撞在桌子上,试图让这个工作。我正在尝试通过 Google App Engine 在 gunicorn 上部署一个简单的 Flask 应用程序。访问该应用程序时,我收到错误 500,并显示“gunicorn:错误:未指定应用程序模块”。在日志中。
我的布局大致是:
Main_Directory/
|-MyApp/
| |-__init__.py <- Containing majority of code
| |-templates/
| |-static/
|-app.yaml
|-main.py
|-requirements.txt
main.py 只是从MyApp 导入应用程序并实例化一个名为“app”的新实例。
requirements.txt 拥有所有依赖项,包括 gunicorn。
app.yaml 如下:
runtime: python37
instance_class: F1
default_expiration: "4d 12h"
entrypoint: gunicorn -b :$PORT -w 1
env_variables:
BUCKET_NAME: "bucket_name"
handlers:
- url: /.*
script: auto
我尝试在 MyApp 文件夹中创建另一个 app.yaml 并添加 service: "default" 但这没有帮助。我在这里几乎没有想法。我相当确定这个问题是因为主应用程序代码是在MyApp 中定义的,而不是直接在Main_directory 下。我很欣赏简单的解决方案是将 MyApp 文件夹中的所有内容提升一个级别,但我犹豫是否这样做,因为它会弄乱我的 Git。我认为创建 main.py 并直接实例化 MyApp/__init__.py 可以解决问题,但似乎不太可行。
任何和所有想法都表示赞赏。
【问题讨论】:
标签: python-3.x google-app-engine flask google-cloud-platform gunicorn