【问题标题】:why 502 error in google app engine flexible environment django?为什么谷歌应用引擎柔性环境django出现502错误?
【发布时间】:2023-03-15 18:35:01
【问题描述】:

我想在谷歌云中部署Django + CloudSQL (Postgresql) + 应用引擎柔性环境。

我的 app.yaml 设置

runtime: python
#gunicorn
env : flex
entrypoint : gunicorn -b 127.0.0.1 -p 8000 config.wsgi --timeout 120

#instance_class : F4

beta_settings:
  cloud_sql_instances: icandoit-2021start:asia-northeast3:test-pybo=tcp:5434

runtime_config:
  python_version: 3

gcloud 应用记录尾部结果

2021-02-03 11:02:17 default[20210203t195827]  [2021-02-03 11:02:17 +0000] [1] [INFO] Starting gunicorn 19.7.1
2021-02-03 11:02:17 default[20210203t195827]  [2021-02-03 11:02:17 +0000] [1] [INFO] Listening at: http://127.0.0.1:8000 (1)
2021-02-03 11:02:17 default[20210203t195827]  [2021-02-03 11:02:17 +0000] [1] [INFO] Using worker: sync
2021-02-03 11:02:17 default[20210203t195827]  [2021-02-03 11:02:17 +0000] [8] [INFO] Booting worker with pid: 8
2021-02-03 11:09:18 default[20210203t170353]  [2021-02-03 11:09:18 +0000] [1] [INFO] Handling signal: term
2021-02-03 11:09:18 default[20210203t170353]  [2021-02-03 11:09:18 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-02-03 11:09:19 default[20210203t170353]  [2021-02-03 11:09:19 +0000] [1] [INFO] Shutting down: Master
2021-02-03 11:09:19 default[20210203t170353]  [2021-02-03 11:09:19 +0000] [1] [INFO] Handling signal: term
2021-02-03 11:09:19 default[20210203t170353]  [2021-02-03 11:09:19 +0000] [8] [INFO] Worker exiting (pid: 8)
2021-02-03 11:09:20 default[20210203t170353]  [2021-02-03 11:09:20 +0000] [1] [INFO] Shutting down: Master
2021-02-03 11:14:25 default[20210203t195827]  "GET /" 502

django 和 gunicon 工作正常。

为什么会出现 502 错误?

【问题讨论】:

    标签: django google-app-engine google-cloud-platform app-engine-flexible


    【解决方案1】:

    请关注官方文档:

    Connecting from App Engine flexible environment to Cloud SQL

    运行时通过运行您在 app.yaml 文件中的入口点字段。入口点应该开始一个 侦听 PORT 环境指定的端口的 Web 服务器 多变的。例如:

    entrypoint: gunicorn -b :$PORT main:app
    

    如果您的应用满足以下要求,App Engine 将启动 如果您不指定 入口点字段:

    您的应用程序目录的根目录包含一个 main.py 文件,其中包含一个 名为 app 的 WSGI 兼容对象。

    您的应用不包含 Pipfile 或 Pipfile.lock 文件。

    App Engine 还会自动将 gunicorn 添加到您的 requirements.txt 文件,如果你不指定入口点字段。

    Python 3 Runtime Environment

    【讨论】:

      猜你喜欢
      • 2021-04-12
      • 2018-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多