

Setting up Django with gunicorn, nginx, supervisord and fabric - KenCochrane
http://kencochrane.net/blog/2011/06/django-gunicorn-nginx-supervisord-fabric-centos55/

======
geekfactor
For my first Django project I spent a few weeks porting an old php site over
to Django and then another couple of weeks trying to get it deployed to my
Linode server.

I really liked Django but the deployment process was very frustrating. I
started with Apache/mod_wsgi which ate up a bunch of time but I eventually
punted and went to gunicorn and nginx which worked pretty well. I also ran
down a bit of a blind alley with buildout but eventually saw the light and
started using virtualenv + pip. I used fabric to automate deployment and
Ubuntu's upstart for process management.

In the end I got the process working pretty well, save a few issues, but it
left a bad taste in my mouth. There was a period of time where I was waiting
to get into the Djangy beta, and I was very optimistic that that would fill
the gap for me, but that company eventually went away, helping to motivate me
to look into Rails so that I could deploy on Heroku. (Note: There seem to be a
couple of viable Django-PaaS options today, including Gondor.io and DotCloud.)

I'm finishing up my first Rails 3 project now and I love it, especially the
Heroku-based deployment model.

P.S. The other motivator for me to jump to Rails was first-class support for
HAML and SASS. I tried all the Python/Django hacks and got them working, but
it was clunky as hell. There have been notable complaints of late about how
fast Rails is changing, but I think the amount of innovation that has been
going on in and around the framework is amazing.

~~~
geekfactor
Why was this downvoted?

~~~
bhoung
most people drawn to this article are python django programmers?

------
ehutch79
I know it's like a LTS type thing, but a new article advocating installing
python 2.6 over 2.7 seems pointless to me at this point. Why would you not
install the latest 2.7?

~~~
bryanh
While he built from source, its worth nothing that Python 2.6 seems to be the
newest version in the yum repos (last time I checked).

------
dennyabraham
I'm unfamiliar with python and supervisord, but is supervisord able to manage
the status of gunicorn and its child processes without explicitly being given
the gunicorn pid? I've been investigating doing the same in Rails (I'll likely
use bluepill) and I'd like to understand how this is done in the python
ecosystem.

~~~
conesus
Supervisor is responsible for starting the gunicorn process, so it knows the
PID when it starts it. Gunicorn controls its own PID file, but supervisor can
send it process signals.

Here's my sample Supervisord conf file for gunicorn:

    
    
        [program:gunicorn]
        directory=/home/sclay/newsblur
        command=gunicorn_django -c config/gunicorn_conf.py
        user=sclay
        autostart=true
        autorestart=true
        #redirect_stderr=True
        priority=991
        stopsignal=HUP
    

Hope that helps.

~~~
dennyabraham
thanks!

------
chaselee
Great post Ken! For anyone who didn't check it out from this article, here's
another awesome post by Ken I spent a lot of time with recently:
[http://kencochrane.net/blog/2011/06/django-hosting-
roundup-w...](http://kencochrane.net/blog/2011/06/django-hosting-roundup-who-
wins/)

------
arthurk
Why Python 2.6 and not 2.7?

~~~
KenCochrane
This blog post was based on a project that I did that required python 2.6.6,
you could use python 2.7 if all of your dependencies support it.

