Seamless Django Deployment on a Single Server

I have a new site built on Django and Python 2.6, which I deployed in the cloud (compatible with the buzzword, and an instance of Amazon micro EC2 is free!).
Here are my detailed notes: https://docs.google.com/document/d/1qcZ_SqxNcFlGKNyp-CXqcFxXXsKs26Avv3mytXGCedA/edit?hl=en_US

Since this is a new site (and you want to play with the latest and greatest), I used Nginx and Gunicorn on top of Supervisor.
All software installed from the trunk using YUM / easy_install.
My Sqlite database (for now - not sure where to go next, but that's not a question). Also on the task list: virtualenv + pip.
So far so good.
My code is in SVN. I wrote a simple file for deployment - it checks the latest code and restarts Gunicorn through Supervisor. I connected my DNS name to Elastic IP.
He works.

My question is: how can I update the site without service interruptions? Site users get 404s / 500s when I run a small script update.

Is there any way to do this without adding another server (key price)?

I would like to have an intermediate system (on another port?) And a seamless switch between Staging and Production. On the same (free) server. Via Fabric.
How should I do it? Is this the same Nginx that works on both sites? Can I update the production without sacrificing production? What would a fabfile look like? What does the directory tree look like?

Thank!

Tal.

Connected:

+5
source share
2 answers

Nginx -, - , , .

, failover, fab, , , , . Nginx , .

, , . .

, . , sqllite, , gunicorn sqllite .

, , , , , .

, . , , .

, .

supervisord gunicorn, supervisorctl /, - , , .

,

nginx config ( , )

, gunicorn 9005, 9006

upstream service-backend {
    server localhost:9005;        # primary
    server localhost:9006 backup; # only used when primary is down
}

server {
    listen 80;
    root /opt/htdocs;
    server_name localhost;

    access_log /var/logs/nginx/access.log;
    error_log  /var/logs/nginx/error.log;

    location / {
        proxy_pass http://service-backend;
    }
}
+3

, , gunicorn . , , , HUP , . , gunicorn docs , .

+1

All Articles