问题描述
我正在尝试在标准Python37环境中的Google App Engine上部署Django应用程序。我有一个在Flexible环境中可以很好运行的版本,但是我正在创建一个要在标准环境中运行的过渡版本。
I'm trying to deploy a Django application on Google App Engine in the Standard Python37 Environment. I've had a version of it running fine in the Flexible environment, but I'm creating a staging version that I want to run in the Standard env.
当我部署并访问该应用程序,出现500错误。查看日志,我可以看到一些有关工作进程异常的消息。我收到错误消息:
When I deploy and visit the app I get a 500 error. Looking in the logs I can see some messages about exceptions in worker processes. I get the error:
这是错误的堆栈跟踪:
文件 /env/lib/python3.7/site-packages/gunicorn/arbiter.py,第583行,位于spawn_worker
worker.init_process()
File "/env/lib/python3.7/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker worker.init_process()
文件 /env/lib/python3.7/site-packages/gunicorn/workers/gthread.py,第104行,init_process
super(ThreadWorker, self).init_process()
File "/env/lib/python3.7/site-packages/gunicorn/workers/gthread.py", line 104, in init_process super(ThreadWorker, self).init_process()
文件 /env/lib/python3.7/site-packages/gunicorn/workers/base.py,第129行,在init_process中
self.load_wsgi()
File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 129, in init_process self.load_wsgi()
文件 /env/lib/python3.7/site-packages/gunicorn/workers/base.py,第138行,在load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.7/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi self.wsgi = self.app.wsgi()
文件 /env/lib/python3.7/site-packages/gunicorn/ app / base.py,第67行,在wsgi
self.callable = self.load()
File "/env/lib/python3.7/site-packages/gunicorn/app/base.py", line 67, in wsgi self.callable = self.load()
文件 /env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py,第52行,在加载
中返回self.load_wsgiapp()
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load return self.load_wsgiapp()
在load_wsgiapp
中,文件 /env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py,第41行,返回util.import_app(self.app_uri)
File "/env/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp return util.import_app(self.app_uri)
文件 /env/lib/python3.7/site-packages/gunicorn/util.py,行350,位于import_app
import (模块)
File "/env/lib/python3.7/site-packages/gunicorn/util.py", line 350, in import_app import(module)
ModuleNotFoundError:没有名为'main'的模块
ModuleNotFoundError: No module named 'main'
我还没有' t自Django为我创建以来,已修改 my_site / wsgi.py
,它是:
I haven't modified my_site/wsgi.py
since Django created it for me, here it is:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "my_site.settings")
application = get_wsgi_application()
这是我的应用。 yaml
:
runtime: python37
env: standard
beta_settings:
cloud_sql_instances: project:us-west1:sql-instance
handlers:
- url: /static
static_dir: staticfiles/
- url: .*
secure: always
redirect_http_response_code: 301
script: my_site.wsgi.application
env_variables:
# vars
这与。
我也尝试将脚本
更改为 auto
,如下所示:,并且 my_site
确实带有下划线,但没有被驼峰化。
I've looked at this question: Django - gunicorn on App Engine. Error: 'No Module Named my_project', and my_site
does have an underscore in it, but isn't camelCased.
我不确定此错误的根源是什么。任何想法将不胜感激。
I'm not sure what the source of this error is. Any ideas would be much appreciated.
推荐答案
您可能需要添加入口点
到您的app.yaml
You may need to add entrypoint
to your app.yaml
runtime: python37
entrypoint: gunicorn -b :8080 my_site.wsgi
...(remaining parts of your app.yaml)
参考:
这篇关于App Engine Standard上的Python 3 Django:应用无法启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!