pythondjangogoogle-app-enginegoogle-cloud-platformgoogle-app-engine-python

Google App Engine Django Project Infinite Loading and error 500 does not raise any error in logs


Im am trying to deploy a Django project on Google Cloud App Engine.

I deployed my app using the command gcloud app deploy.

As I try to load the page in my browser, there is an infinite loading until the page finally returns a "Server 500 Error".

I decited then to see if there is something weird in the logs by executing gcloud app logs tail but it does not raise any type of error, this is what i get.

2021-11-26 17:38:31 default[version_code]  [2021-11-26 17:38:31 +0000] [11] [INFO] Starting gunicorn 20.1.0
2021-11-26 17:38:31 default[version_code]  [2021-11-26 17:38:31 +0000] [11] [INFO] Listening at: http://0.0.0.0:8000 (11)
2021-11-26 17:38:31 default[version_code]  [2021-11-26 17:38:31 +0000] [11] [INFO] Using worker: sync
2021-11-26 17:38:31 default[version_code]  [2021-11-26 17:38:31 +0000] [16] [INFO] Booting worker with pid: 16

ALSO IN ERROR REPORTING PAGE OF GOOGLE CLOUD NOTHING APPEARS

This is my Python Django settings.py:

if os.getenv('GAE_APPLICATION', None):
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql',
            'HOST': 'cloudsql/<my-google-cloudsql-connection-string>',
            'NAME': 'database_name',
            'USER': 'username',
            'PASSWORD': 'password',
            'PORT': '5432',
        }
    }
else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': BASE_DIR / 'db.sqlite3',
        }
    }

This is my app.yaml file:

runtime: python39
env: standard
app_engine_apis: true
handlers:
- url: /static
  static_dir: static/
- url: /.*
  script: auto

entrypoint: gunicorn -b :8000 NG.wsgi

I also get this warning during the deploy: Updating service [default]...|WARNING: There is a dependency on App Engine APIs, but they are not enabled in your app.yaml. Set the app_engine_apis property..

In my app.yaml I configured the app_engine_apis property, so, why is it raising the Warning?

EDIT 1:

I just checked if the problem is generated by the database connection, but actually, it's not. If there isn't any error, the page doesn't even load, what I think is that I messed up some configuration, but, I just followed the steps on the official WebSite of GoogleCloud


Solution

  • I solved the error by just removing this line on app.yaml file.

    That's the line entrypoint: gunicorn -b :8000 NG.wsgi

    I guess you do not have to specify the entrypoint when deploying a Django application on App Engine.