简体   繁体   中英

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. 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

Looking for similar issues with the "500 server error" I found something that can be useful for you.

Apparently this error is received due to application errors as suggested here , the user also talks about taking a look at the deployment settings since the production and local hosts are different and set DEBUG = TRUE . Here is a guide on how to configure your app for production .

Another question points to look for the Error Reporting panel in Google Cloud Platform dashboard to get a stacktrace to the problem in your code, if it is there. This can be helpful to solve a 500 error.

In the same question a user answers this issue is hard to solve straightforwardly and that you need to investigate for various reasons as we can see in this discussion , where they asked the OP for their logs to provide further help. Then, after checking them the OP got his own solution.

I would suggest looking at the configuration to check everything is ok for production deployment, try to check for more information in the Error Reporting panel and if you have the logs and you are still not able to troubleshoot the issue posting another or updating the question with this information.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM