Hey everyone,

I'm attempting to run some virtualenv apps with uwsgi using the vhost
and no-site options, and I've got everything working great except for
a small error.  If I have 1 server_name of example.aaa.com and another
of example2.aaa.com, the first time I load each one, everything works
fine.  However, when attempting to load them on subsequent requests,
uwsgi becomes confused and will show the wrong virtualenv (it shows
the example2 virtualenv when requesting example.aaa.com one out of
every 5 times or so).

Looking at the debug logs, it looks like the proper server_name is
being detected, but for some reason the chdir is not always set
correctly.  The relevant information from the nginx config and my
uwsgi config are below with the logs as well.

I'm using uWSGI 0.9.8.2 compiled with Python 2.6 (and both virtualenvs
are also running python 2.6) with debugging enabled.

NGINX:

/etc/nginx/sites-enabled/example.aaa.com:

        include         uwsgi_params;
        uwsgi_param     UWSGI_PYHOME    /opt/webapps/example.aaa.com;
        uwsgi_param     UWSGI_CHDIR     /opt/webapps/example.aaa.com;
        uwsgi_param     UWSGI_SCRIPT    config.django_wsgi;
        uwsgi_param     SCRIPT_NAME     /;
        uwsgi_modifier1 30;


/etc/nginx/sites-enabled/example2.aaa.com:

        include         uwsgi_params;
        uwsgi_param     UWSGI_PYHOME    /opt/webapps/example2.aaa.com;
        uwsgi_param     UWSGI_CHDIR     /opt/webapps/example2.aaa.com;
        uwsgi_param     UWSGI_SCRIPT    config.django_wsgi;
        uwsgi_param     SCRIPT_NAME     /;
        uwsgi_modifier1 30;

/etc/uwsgi/conf.yml
uwsgi:
        master: true
        processes: 3
        memory-report: true
        harakiri: 30
        vacuum: true
        max-requests: 500
        reload-on-as: 256
        reload-on-rss: 128
        vhost: true
        no-site: true
        daemonize: /var/log/uwsgi.log
        socket: /tmp/uwsgi.sock

uWSGI DEBUG LOG (this was achieved by refreshing
http://example.aaa.com over and over again until I got a valid
response followed by an invalid response):

[uWSGI DEBUG] uwsgi payload size: 1008 (0x3F0) modifier1: 30 modifier2: 0
[uWSGI DEBUG] PATH_INFO=/
[uWSGI DEBUG] SERVER_NAME=example.aaa.com
[uWSGI DEBUG] SCRIPT_NAME=/
[uWSGI DEBUG] VirtualHost SCRIPT_NAME=example.aaa.com|/
searching for example.aaa.com|/ in  (nil)
searching for example.aaa.com|/ in example2.aaa.com| 0xb6f14c8c
searching for example.aaa.com|/ in example.aaa.com| 0x96736cc
searching for example.aaa.com| in  (nil)
searching for example.aaa.com| in example2.aaa.com| 0xb6f14c8c
searching for example.aaa.com| in example.aaa.com| 0x96736cc
mountpoint example.aaa.com| already configured. skip.
[uWSGI DEBUG] chdir to /opt/webapps/example.aaa.com
[uWSGI DEBUG] QUERY_STRING:
[uWSGI DEBUG] REQUEST_METHOD: GET
[uWSGI DEBUG] CONTENT_TYPE:
[uWSGI DEBUG] CONTENT_LENGTH:
[uWSGI DEBUG] REQUEST_URI: /
[uWSGI DEBUG] PATH_INFO: /
[uWSGI DEBUG] DOCUMENT_ROOT: /var/www/example.aaa.com
[uWSGI DEBUG] SERVER_PROTOCOL: HTTP/1.1
[uWSGI DEBUG] REMOTE_ADDR: 67.181.192.127
[uWSGI DEBUG] REMOTE_PORT: 52326
[uWSGI DEBUG] SERVER_PORT: 80
[uWSGI DEBUG] SERVER_NAME: example.aaa.com
[uWSGI DEBUG] UWSGI_PYHOME: /opt/webapps/example.aaa.com
[uWSGI DEBUG] UWSGI_CHDIR: /opt/webapps/example.aaa.com
[uWSGI DEBUG] UWSGI_SCRIPT: config.django_wsgi
[uWSGI DEBUG] SCRIPT_NAME: /
[uWSGI DEBUG] HTTP_HOST: example.aaa.com
[uWSGI DEBUG] HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:5.0) Gecko/20100101 Firefox/5.0
[uWSGI DEBUG] HTTP_ACCEPT:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[uWSGI DEBUG] HTTP_ACCEPT_LANGUAGE: en-us,en;q=0.5
[uWSGI DEBUG] HTTP_ACCEPT_ENCODING: gzip, deflate
[uWSGI DEBUG] HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
[uWSGI DEBUG] HTTP_CONNECTION: keep-alive
[uWSGI DEBUG] HTTP_COOKIE: __qca=P0-425042788-1303766174937;
__utma=156073896.916398795.1303766393.1308700520.1310665912.5;
__utmz=156073896.1310665912.5.3.utmcsr=spikemind.com|utmccn=(referral)|utmcmd=referral|utmcct=/about/
[uWSGI DEBUG] HTTP_CACHE_CONTROL: max-age=0
[uWSGI DEBUG] called 0x96736cc 0x9668ccc 1
example.aaa.com {address space usage: 22564864 bytes/21MB} {rss usage:
16822272 bytes/16MB} [pid: 6394|app: 2|req: 17/139] 67.181.192.127 ()
{50 vars in 1008 bytes} [Wed Jul 20 23:19:33 2011] GET / => generated
16 bytes in 1 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches
on core 0)

[uWSGI DEBUG] uwsgi payload size: 1008 (0x3F0) modifier1: 30 modifier2: 0
[uWSGI DEBUG] PATH_INFO=/
[uWSGI DEBUG] SERVER_NAME=example.aaa.com
[uWSGI DEBUG] SCRIPT_NAME=/
[uWSGI DEBUG] VirtualHost SCRIPT_NAME=example.aaa.com|/
searching for example.aaa.com|/ in  (nil)
searching for example.aaa.com|/ in example.aaa.com| 0xb6f13c8c
searching for example.aaa.com|/ in example2.aaa.com| 0x96736cc
searching for example.aaa.com| in  (nil)
searching for example.aaa.com| in example.aaa.com| 0xb6f13c8c
mountpoint example.aaa.com| already configured. skip.
[uWSGI DEBUG] chdir to /opt/webapps/example2.aaa.com
[uWSGI DEBUG] QUERY_STRING:
[uWSGI DEBUG] REQUEST_METHOD: GET
[uWSGI DEBUG] CONTENT_TYPE:
[uWSGI DEBUG] CONTENT_LENGTH:
[uWSGI DEBUG] REQUEST_URI: /
[uWSGI DEBUG] PATH_INFO: /
[uWSGI DEBUG] DOCUMENT_ROOT: /var/www/example.aaa.com
[uWSGI DEBUG] SERVER_PROTOCOL: HTTP/1.1
[uWSGI DEBUG] REMOTE_ADDR: 67.181.192.127
[uWSGI DEBUG] REMOTE_PORT: 52326
[uWSGI DEBUG] SERVER_PORT: 80
[uWSGI DEBUG] SERVER_NAME: example.aaa.com
[uWSGI DEBUG] UWSGI_PYHOME: /opt/webapps/example.aaa.com
[uWSGI DEBUG] UWSGI_CHDIR: /opt/webapps/example.aaa.com
[uWSGI DEBUG] UWSGI_SCRIPT: config.django_wsgi
[uWSGI DEBUG] SCRIPT_NAME: /
[uWSGI DEBUG] HTTP_HOST: example.aaa.com
[uWSGI DEBUG] HTTP_USER_AGENT: Mozilla/5.0 (Windows NT 6.1; WOW64;
rv:5.0) Gecko/20100101 Firefox/5.0
[uWSGI DEBUG] HTTP_ACCEPT:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
[uWSGI DEBUG] HTTP_ACCEPT_LANGUAGE: en-us,en;q=0.5
[uWSGI DEBUG] HTTP_ACCEPT_ENCODING: gzip, deflate
[uWSGI DEBUG] HTTP_ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.7
[uWSGI DEBUG] HTTP_CONNECTION: keep-alive
[uWSGI DEBUG] HTTP_COOKIE: __qca=P0-425042788-1303766174937;
__utma=156073896.916398795.1303766393.1308700520.1310665912.5;
__utmz=156073896.1310665912.5.3.utmcsr=spikemind.com|utmccn=(referral)|utmcmd=referral|utmcct=/about/
[uWSGI DEBUG] HTTP_CACHE_CONTROL: max-age=0
[uWSGI DEBUG] called 0x96736cc 0x9668ccc 1
example.aaa.com {address space usage: 22560768 bytes/21MB} {rss usage:
16965632 bytes/16MB} [pid: 6396|app: 2|req: 89/140] 67.181.192.127 ()
{50 vars in 1008 bytes} [Wed Jul 20 23:19:34 2011] GET / => generated
28 bytes in 1 msecs (HTTP/1.1 200) 1 headers in 59 bytes (1 switches
on core 0)

Ryan-
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi

Reply via email to