将 Django 应用程序部署到 App Engine 柔性环境
Deploying a Django App to App Engine Flexible Environment
我正在尝试部署 sample app to the Google App Engine Flexible Environment based on this 教程。部署有效,但是应用程序无法启动。我收到以下错误消息:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2017-01-21 17:01:14 +0000] [5] [INFO] Starting gunicorn 19.6.0
[2017-01-21 17:01:14 +0000] [5] [INFO] Listening at: http://0.0.0.0:8080 (5)
[2017-01-21 17:01:14 +0000] [5] [INFO] Using worker: sync
[2017-01-21 17:01:14 +0000] [8] [INFO] Booting worker with pid: 8
[2017-01-21 17:01:14 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/env/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/env/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
__import__(module)
ImportError: No module named 'mysite'
[2017-01-21 17:01:14 +0000] [8] [INFO] Worker exiting (pid: 8)
[2017-01-21 17:01:14 +0000] [5] [INFO] Shutting down: Master
[2017-01-21 17:01:14 +0000] [5] [INFO] Reason: Worker failed to boot.
正如您在 GitHub 上看到的(参见上面的 link),/app.yaml 文件如下所示:
# [START runtime]
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT mysite.wsgi
beta_settings:
cloud_sql_instances: <your-cloudsql-connection-string>
runtime_config:
python_version: 3
# [END runtime]
/mysite/wsgi.py 文件如下:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
由于柔性环境处于测试阶段,我不确定这是否是一个错误。但是,我使用的是 GitHub 的原始应用程序,没有按照官方文档进行任何更改,因此我希望它能正常工作。
感谢您的帮助。
尝试:
entrypoint: gunicorn -b :$PORT mysite.wsgi:application
(假设目录"mysite"与app.yaml
处于同一级别。如果wsgi.py
与app.yaml
处于同一级别,则只需::$PORT wsgi:application
)
感谢 Adam(Google Group Forum 上的 Google Cloud Platform 团队成员)提示文件可能未部署,我从 138.0 更新了 Google Cloud SDK .0 到 141.0.0。现在一切正常,如教程中所述。
确保满足您的要求,即将 requirements.txt 复制到项目的根目录
看起来像这样
Django==1.11.1
mysqlclient==1.3.10
wheel==0.29.0
gunicorn==19.7.1
psycopg2==2.7.1
和运行
pip install -r requirements.txt
然后 gcloud app deploy
我正在尝试部署 sample app to the Google App Engine Flexible Environment based on this 教程。部署有效,但是应用程序无法启动。我收到以下错误消息:
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
[2017-01-21 17:01:14 +0000] [5] [INFO] Starting gunicorn 19.6.0
[2017-01-21 17:01:14 +0000] [5] [INFO] Listening at: http://0.0.0.0:8080 (5)
[2017-01-21 17:01:14 +0000] [5] [INFO] Using worker: sync
[2017-01-21 17:01:14 +0000] [8] [INFO] Booting worker with pid: 8
[2017-01-21 17:01:14 +0000] [8] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/env/lib/python3.5/site-packages/gunicorn/arbiter.py", line 557, in spawn_worker
worker.init_process()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 126, in init_process
self.load_wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/workers/base.py", line 136, in load_wsgi
self.wsgi = self.app.wsgi()
File "/env/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/env/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/env/lib/python3.5/site-packages/gunicorn/util.py", line 357, in import_app
__import__(module)
ImportError: No module named 'mysite'
[2017-01-21 17:01:14 +0000] [8] [INFO] Worker exiting (pid: 8)
[2017-01-21 17:01:14 +0000] [5] [INFO] Shutting down: Master
[2017-01-21 17:01:14 +0000] [5] [INFO] Reason: Worker failed to boot.
正如您在 GitHub 上看到的(参见上面的 link),/app.yaml 文件如下所示:
# [START runtime]
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT mysite.wsgi
beta_settings:
cloud_sql_instances: <your-cloudsql-connection-string>
runtime_config:
python_version: 3
# [END runtime]
/mysite/wsgi.py 文件如下:
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
application = get_wsgi_application()
由于柔性环境处于测试阶段,我不确定这是否是一个错误。但是,我使用的是 GitHub 的原始应用程序,没有按照官方文档进行任何更改,因此我希望它能正常工作。
感谢您的帮助。
尝试:
entrypoint: gunicorn -b :$PORT mysite.wsgi:application
(假设目录"mysite"与app.yaml
处于同一级别。如果wsgi.py
与app.yaml
处于同一级别,则只需::$PORT wsgi:application
)
感谢 Adam(Google Group Forum 上的 Google Cloud Platform 团队成员)提示文件可能未部署,我从 138.0 更新了 Google Cloud SDK .0 到 141.0.0。现在一切正常,如教程中所述。
确保满足您的要求,即将 requirements.txt 复制到项目的根目录
看起来像这样
Django==1.11.1
mysqlclient==1.3.10
wheel==0.29.0
gunicorn==19.7.1
psycopg2==2.7.1
和运行
pip install -r requirements.txt
然后 gcloud app deploy