Django: What is the difference between manage.py and gunicorn project.wsgi - django

I deployed a django project and everything works great on manage.py, but when I run the default gunicorn server via gunicorn projectname.wsgi, the registration form cannot be submitted and there is a 502 Bad Request Error.
Any ideas?

manage.py runserver seems to boot the celery workers automatically while gunicorn.wsgi does not. Booting all the workers fixed the problem.
Thanks for the comments!

Related

How to restart Foreman when code in a Django site changes?

I'm running a Django website in a Vagrant box that (roughly) mirrors a Heroku set-up. It uses Foreman with a Procfile like this:
web: gunicorn projectname.wsgi > /vagrant/gunicorn.log 2>&1
However, when I change my Django code, the server doesn't restart or reload the code, which makes development... painful!
How can I make Foreman serve the new code when it changes?

How to use Django logging with gunicorn

I have a Django 1.6 site running with gunicorn, managed by supervisor. During tests and runserver I have logging on the console, but with gunicorn the statements don't show up anywhere (not even ERROR level logs). They should be in /var/log/supervisor/foo-stderr---supervisor-51QcIl.log but they're not. I have celery running on a different machine using supervisor and its debug statements show up fine in its supervisor error file.
Edit:
Running gunicorn in the foreground shows that none of my error messages are being logged to stderr like they are when running manage.py. This is definitely a gunicorn problem and not a supervisor problem.
I got a response on GitHub:
https://github.com/benoitc/gunicorn/issues/708
Since you have passed disable_existing_loggers the Gunicorn loggers are disabled when Django loads your logging configuration. If you are setting this because you want to disable some default Django logging configuration, make sure you add back the gunicorn loggers, gunicorn.error and gunicorn.access with whatever handlers you want.
In /etc/supervisor/conf.d/your-app.confyou should set log paths:
stdout_logfile=/var/log/your-app.log
stderr_logfile=/var/log/your-app.log
First, in your supervisor config for the gunicorn script, be sure to define
stdout_logfile=/path/to/logfile.log
redirect_stderr=true
That will make stdout and stderr go to the same file.
Now, on your gunicorn script, be sure to call the process with the following argument
gunicorn YourWSGIModule:app --log-level=critical

Django + Nginx: 502 Bad Gateway on registration

What is the difference in the way manage.py runserver serves up a django project compared to gunicorn.wsgi?
I am using nginx + gunicorn to serve my django project. Everything seems to work fine, but when users try to register, they get a 502 Bad Gateway. However, when I run the server off of the development manage.py runserver, the registration goes through fine.
So, what is the difference between manage.py runserver and gunicorn.wsgi and what can I do to make sure gunicorn is configured properly?
Please let me know if you need more details. Thanks

Heroku: My Django app is giving Application Error H14: "No Web Processes Running"

According to the Heroku site when I get error H14 "No Web Processes Running" it's because I need to scale up dynos by:
heroku ps:scale web=1
However, when I do that I get the following error:
Scaling web processes... failed
! No such type as web
Does anyone know how to fix this? I want to get my site back up!
When I run heroku ps I see nothing.
UPDATE: It's not detecting my Procfile. I don't have a Procfile explicitly and didn't use one before... is it absolutely necessary?
I ran into this recently as well, my web was working fine without any Procfile, until recently...
My fix was simply to add a Procfile as follows:
web: python manage.py runserver 0.0.0.0:$PORT --noreload
Then push to heroku.
For Heroku you need to add a Procfile.
add a Procfile on same level like your manage.py file. It should be in your root directory. Be sure that you create a Procfile not a Procfile.txt or else just Procfile
in your Procfile add:
web: gunicorn projectname.wsgi
add in your requirements.txt gunicorn
gunicorn==20.0.4
If you activate automatic deploy you can try it again.
If you can remove the app, remove it and deploy it again.

How to deploy mezzanine on heroku?

I have created a mezzanine project and its name is mezzanine-heroku-test
I create a Procfile that has the content as follow:
web: python manage.py run_gunicorn -b "0.0.0.0:$PORT" -w 3
Next, I access to the website to test and I receive the error: Internal Server Error.
So, Could you please help me deploy mezzanine on heroku step by step or some suggestion?
Thank you so much.
You should be able to see the error in the logs which you can get to using the heroku tool.
heroku logs
These are both thorough.
https://gist.github.com/joshfinnie/4046138
http://www.benhavilland.com/blog/deploying-mezzanine-on-heroku/
This is a challenging process.