【问题标题】:Google App Engine deployment issue- main app not foundGoogle App Engine 部署问题 - 找不到主应用
【发布时间】:2019-01-30 14:47:19
【问题描述】:

我正在尝试使用 Google App Engine 部署我的应用程序。我编辑了 app.yaml 以反映灵活的环境,并提供了所有应用程序信息。下面是 app.yaml 文件。

runtime: python
env: flex
entrypoint: gunicorn -b :$PORT main:app
runtime_config:
  python_version: 3

在部署过程中,我收到以下错误

[2018-08-24 06:57:14 +0000] [1] [INFO] Starting gunicorn 19.7.1
[2018-08-24 06:57:14 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[2018-08-24 06:57:14 +0000] [1] [INFO] Using worker: sync
[2018-08-24 06:57:14 +0000] [7] [INFO] Booting worker with pid: 7
App Deployed
Failed to find application: 'main'
[2018-08-24 06:57:14 +0000] [7] [INFO] Worker exiting (pid: 7)
[2018-08-24 06:57:14 +0000] [1] [INFO] Shutting down: Master
[2018-08-24 06:57:14 +0000] [1] [INFO] Reason: App failed to load.

请注意,App Deployed 是我的打印声明中的一行。它正在被执行。但是部署失败了

提前谢谢你

【问题讨论】:

  • 你的 main.py 文件在哪里?它应该在您运行gcloud app deploy command的文件夹内。
  • 是 @Yurci .. 它在我有 app.yaml、requirements.txt 和 python 代码的文件夹内(main.py)

标签: python google-app-engine google-cloud-platform google-cloud-storage app.yaml


【解决方案1】:

在您的 app.yaml 中,您将使用 gunicorn -b :$PORT main:app 开始 gunicorn。这告诉它在文件main.py中查找对象app

The error you're getting comes from gunicorn 并在您有一个 main.py 文件但其中没有 app 对象时发生。

您可能希望按如下方式设置 Flask 应用程序:

from flask import Flask

app = Flask(__name__)

在此处查看完整的示例应用程序:https://cloud.google.com/appengine/docs/flexible/python/quickstart#hello_world_code_review

【讨论】:

    【解决方案2】:

    我也遇到了同样的问题。

    Failed to find application: 'main'
    

    在我的情况下,原因是我在根项目目录中有一个名为 main 的目录。

    drwxr-xr-x   2 user  staff    64 Nov 30 10:12 main
    -rw-r--r--   1 user  staff  1178 Nov 29 20:58 main.py
    

    我猜 gunicorn 搞糊涂了。 解决方案(对我有用):重命名main 目录。

    附:只是不要将其重命名为code 目录。这将导致 PyCharm 中的另一个调试问题。 :)

    【讨论】:

      【解决方案3】:

      我的文件夹结构看起来像这样 main.py 不在 root 目录中,我如何在 app.yaml 文件中指定它。

      /app
       |__main.py
      app.yaml
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-24
        • 2015-11-13
        • 2020-01-22
        • 2015-02-19
        • 2017-09-04
        • 1970-01-01
        • 1970-01-01
        • 2021-12-30
        相关资源
        最近更新 更多