1
votes

I want to deploy Django + CloudSQL (Postgresql) + app engine flexible environment in google cloud.

My app.yaml setting

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 app logs tail result

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 and gunicon works normally.

Why Do I Have 502 Errors?

1

1 Answers

0
votes

Please follow the official documentation about :

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