简体   繁体   中英

Production.py issue with deployment of cookiecutter-django and gunicorn to digital ocean

I built a Django project using the latest version of cookiecutter-django , which seems to be working fine on my local computer as well as when I run it through python manage.py runserver using the various settings files. I'm trying to test my Gunicorn server on Digital Ocean (running Ubuntu 16.04) but for some reason can't get the server to run properly when production.py is the one being used.

When I do the following command on bash:

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

everything works fine and I get these:

[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

But when I don't specify the settings file and default to production.py with gunicorn --bind 0.0.0.0:8000 --preload config.wsgi , where the environment variable DJANGO_SETTINGS_MODULE is set to config.settings.production , I only get these:

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.

And it pretty much just gets stuck there. What might be causing this issue?

Looks like it was an SSL problem. By default, cookiecutter-django forces HTTPS but my server doesn't yet have any certificates so it was failing. I added the following section to the ~/.bashrc file and it worked:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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