How to best use gunicorn with multiple virtualenv's

235 views
Skip to first unread message

Benedict Verheyen

unread,
Jul 20, 2011, 2:55:16 AM7/20/11
to django...@googlegroups.com
Hi,


I just discovered gunicorn after some problems with wsgi.
It seems like a very clean setup together with supervisord.
However, it's not clear to me how you set it up when you
have multiple virtualenvs.

It's easy enough to install gunicorn in a virtualenv and then
specify a upstream <app_server> in nginx.conf.
This is the part that bugs me.
Do you specify an upstream server for every virtualenv (and thus
website)?
For instance, something like this:

nginx.conf
...
http {
upstream app_server_1 {
server 127.0.0.1:8000 fail_timeout=0;
}
upstream app_server_2 {
server 127.0.0.1:8001 fail_timeout=0;
}
server {
listen 80;
server_name app_1;
location / {
...
proxy_pass http://app_server_1;
...
}
}
server {
listen 80;
server_name app_2;
location / {
...
proxy_pass http://app_server_2;
...
}
}
}

The apps are then started with gunicorn_django and following configs:

gunicorn.conf.py for app_1
bind = "127.0.0.1:8000"
workers = 3
...

gunicorn.conf.py for app_2
bind = "127.0.0.1:8001"
workers = 3
...

Is this is sound setup or to much overhead?
It's seems ok however, I do get a warning from nginx:

Restarting nginx:
[warn]: conflicting server name "app_1" on 0.0.0.0:80, ignored
[warn]: conflicting server name "app_2" on 0.0.0.0:80, ignored


Are there other ways to serve multiple sites from different
virtualenv's?

Cheers,
Benedict

Shawn Milochik

unread,
Jul 20, 2011, 8:59:28 AM7/20/11
to django...@googlegroups.com
I just create a different user account for each application I'm
running. So each user account has its own virtualenv, gunicorn, etc.
Obviously just one nginx instance.
Reply all
Reply to author
Forward
0 new messages