为什么 google App Engine 柔性环境 django 中出现 502 错误?

why 502 error in google app engine flexible environment django?

我想在 google 云中部署 Django + CloudSQL (Postgresql) + App Engine 柔性环境。

我的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 错误?

请参考官方文档:

Connecting from App Engine flexible environment to Cloud SQL

The runtime starts your app by running the command you specify in the entrypoint field in your app.yaml file. The entrypoint should start a web server that listens on the port specified by the PORT environment variable. For example:

entrypoint: gunicorn -b :$PORT main:app

If your app meets the following requirements, App Engine will start your app with the gunicorn web server if you don't specify the entrypoint field:

The root of your app directory contains a main.py file with a WSGI-compatible object called app.

Your app does not contain Pipfile or Pipfile.lock files.

App Engine will also automatically add the gunicorn to your requirements.txt file if you don't specify the entrypoint field.

Python 3 Runtime Environment