简体   繁体   English

将Django应用部署到App Engine灵活环境

[英]Deploying a Django App to App Engine Flexible Environment

I am trying to deploy a sample app to the Google App Engine Flexible Environment based on this tutorial. 我正在尝试根据教程将示例应用程序部署到Google App Engine灵活环境。 The deployment works, however, the application cannot start up. 部署工作正常,但是应用程序无法启动。 I get the following error message: 我收到以下错误消息:

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.

As you can see on GitHub (see link above), the /app.yaml file looks like this: 如您在GitHub上所见(请参见上面的链接),/ 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]

And the /mysite/wsgi.py file like this: /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()

Since the Flexible Environment is in beta, I am not sure if this might be a bug. 由于弹性环境处于测试阶段,因此我不确定这是否是错误。 However, I am using the original app from GitHub without any changes following the official documentation, so I would expect it to work. 但是,我使用的是GitHub上的原始应用程序,但未遵循官方文档进行任何更改,因此我希望它能正常工作。

I appreciate your help. 我感谢您的帮助。

Try: 尝试:

entrypoint: gunicorn -b :$PORT mysite.wsgi:application

(assuming the directory "mysite" is at the same level as app.yaml . If wsgi.py is at the same level as app.yaml , then just: :$PORT wsgi:application ) (假设目录“mysite的”处于同一级别app.yaml如果。 wsgi.py处于同一水平app.yaml ,然后只是: :$PORT wsgi:application

Thanks to the hint from Adam (Google Cloud Platform team member on the Google Group Forum ) that the files are probably not getting deployed, I updated the Google Cloud SDK from 138.0.0 to 141.0.0. 由于Adam(Google Group论坛上的Google Cloud Platform团队成员)暗示文件可能未部署,因此我将Google Cloud SDK从138.0.0更新为141.0.0。 Now everything works fine as described in the tutorial. 现在,一切都可以按照本教程中的描述正常运行。

Ensure that your requirements have been met, ie copy requirements.txt to the root of your project 确保满足您的要求,即将Requirement.txt复制到项目的根目录

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/django_cloudsql/requirements.txt https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/django_cloudsql/requirements.txt

which looks like this 看起来像这样

Django==1.11.1
mysqlclient==1.3.10
wheel==0.29.0
gunicorn==19.7.1
psycopg2==2.7.1

and run 并运行

pip install -r requirements.txt

Then gcloud app deploy 然后部署gcloud应用

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

相关问题 Django - Google App Engine 灵活 ENV 上的 SendMail - Django - SendMail on Google App Engine Flexible ENV Google App Engine灵活环境中的原始自定义日志 - Raw Custom Logs in Google App Engine Flexible Environment Google Cloud App Engine:如何在灵活的环境中提供https - Google Cloud App Engine: How to serve https in a Flexible environment Google App Engine 柔性环境是否支持 pyodbc? - Does Google App Engine Flexible Environment support pyodbc? 使用 Django 在 Google App Engine Flexible 上永久重定向 http 到 https - Permanently Redirect http to https on Google App Engine Flexible with Django Python Google应用引擎灵活 - Python google app engine flexible 部署到Google App Flexible Engine时firebase_helper.py中的Crypto.Util导入错误 - Crypto.Util import error in firebase_helper.py when deploying to Google App Flexible Engine 在 App Engine Python 中向 Google Datastore 实体动态添加属性(灵活环境) - Add properties to Google Datastore entity dynamically in App Engine Python (Flexible environment) 如何在Google App Engine灵活环境中编辑NGINX配置? - How can I edit the NGINX configuration on Google App Engine flexible environment? “无法在Google App Engine灵活环境中导入google / appengine / ext / deferred / handler.py” - “Failed to import google/appengine/ext/deferred/handler.py” in Google App Engine Flexible Environment
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM