【问题标题】:Production.py issue with deployment of cookiecutter-django and gunicorn to digital ocean将 cookiecutter-django 和 gunicorn 部署到数字海洋的 Production.py 问题
【发布时间】:2018-07-29 07:13:18
【问题描述】:

我使用最新版本的cookiecutter-django 构建了一个 Django 项目,它似乎在我的本地计算机上运行良好,当我使用各种设置文件通过python manage.py runserver 运行它时。我正在尝试在 Digital Ocean(运行 Ubuntu 16.04)上测试我的 Gunicorn 服务器,但由于某种原因,当使用 production.py 时,服务器无法正常运行。

当我在 bash 上执行以下命令时:

gunicorn --bind 0.0.0.0:8000 --env DJANGO_SETTINGS_MODULE=config.settings.test --preload config.wsgi

一切正常,我得到了这些:

[2018-02-18 23:31:14 -0500] [31662] [INFO] Starting gunicorn 19.7.1
[2018-02-18 23:31:14 -0500] [31662] [INFO] Listening at: http://0.0.0.0:8000 (31662)
[2018-02-18 23:31:14 -0500] [31662] [INFO] Using worker: sync
[2018-02-18 23:31:14 -0500] [31666] [INFO] Booting worker with pid: 31666

但是当我没有指定设置文件并默认为production.pygunicorn --bind 0.0.0.0:8000 --preload config.wsgi,其中环境变量DJANGO_SETTINGS_MODULE设置为config.settings.production时,我只能得到这些:

DEBUG 2018-02-18 23:31:55,786 base 31681 140442914699008 Configuring Raven for host: <raven.conf.remote.RemoteConfig object at 0x7fbb5cc0b668>
INFO 2018-02-18 23:31:55,786 base 31681 140442914699008 Raven is not configured (logging is disabled). Please see the documentation for more information.

它几乎只是卡在那里。什么可能导致此问题?

【问题讨论】:

    标签: python django gunicorn digital-ocean cookiecutter-django


    【解决方案1】:

    看起来这是一个 SSL 问题。默认情况下,cookiecutter-django 强制使用 HTTPS,但我的服务器还没有任何证书,所以它失败了。我在~/.bashrc 文件中添加了以下部分并且它起作用了:

    ## for testing 
    export DJANGO_DEBUG=False (can be True when testing)
    export DJANGO_SECURE_SSL_REDIRECT=True (can be False when testing)
    

    【讨论】:

      猜你喜欢
      • 2015-05-03
      • 2015-03-14
      • 2017-09-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 2017-12-12
      • 2016-05-30
      相关资源
      最近更新 更多