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