简体   繁体   English

Google App Engine Django 项目无限加载和错误 500 不会在日志中引发任何错误

[英]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.我正在尝试在 Google Cloud App Engine 上部署 Django 项目。

I deployed my app using the command gcloud app deploy .我使用命令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".当我尝试在浏览器中加载页面时,会无限加载,直到页面最终返回“服务器 500 错误”。

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.然后我决定通过执行gcloud app logs tail来查看日志中是否有奇怪的东西,但它不会引发任何类型的错误,这就是我得到的。

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 :这是我的 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:这是我的app.yaml文件:

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. 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?在我的app.yaml 中,我配置了app_engine_apis属性,那么,为什么会引发警告?

EDIT 1:编辑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.寻找与“500 服务器错误”类似的问题,我发现了一些对您有用的东西。

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 .显然,由于此处建议的应用程序错误而收到此错误,用户还谈到查看部署设置,因为生产和本地主机不同并设置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.另一个问题指向在 Google Cloud Platform 仪表板中查找错误报告面板,以获取代码中问题的堆栈跟踪(如果存在)。 This can be helpful to solve a 500 error.这有助于解决 500 错误。

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.在同一个问题中,用户回答这个问题很难直接解决,正如我们在这个讨论中看到的那样,您需要调查各种原因,他们要求 OP 提供他们的日志以提供进一步的帮助。 Then, after checking them the OP got his own solution.然后,在检查了他们之后,OP 得到了他自己的解决方案。

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.我通过删除app.yaml文件上的这一行来解决该错误。

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

I guess you do not have to specify the entrypoint when deploying a Django application on App Engine.我猜您在 App Engine 上部署 Django 应用程序时不必指定入口点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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