Hi list,
I'm having an impossible time getting a Flask app to see any environment
variables I try and pass through from nginx using the "uwsgi_param
UWSGI_SETENV VARNAME=FOO" method.
Trying to access these vars via os.environ['VARNAME'] always throws a
KeyError exception. Interestingly, passing an env variable to the Flask
app via the uwsgi config file itself works as expected.
The Flask app is running as a vassal of the emperor (in its own
virtualenv) and copied below are the relevant bits of my config.
The emperor is running with these arguments:
--emperor /srv/uwsgi/vassals/enabled --pidfile2
/srv/uwsgi/run/emperor.pid --daemonize /srv/uwsgi/log/emperor.log
--logdate true
The uwsgi config file for the Flask vassal (in yaml format) is:
uwsgi:
uid: uwsgi
gid: www-data
socket: 127.0.0.1:9000
workers: 4
harakiri: 60
reload-mercy: 8
max-requests: 5000
reload-on-as: 128
reload-on-rss: 96
thread-stacksize: 512
daemonize: /srv/uwsgi/log/%n.log
pidfile2: /srv/uwsgi/run/%n.pid
log-x-forwarded-for: true
limit-post: 131072
no-orphans: true
no-default-app: true
logdate: true
vacuum: true
master: 1
plugins: python26
chdir: /srv/webapps/%n
chdir2: /srv/webapps/%n
home: /srv/webapps/%n/venv
pythonpath: /srv/webapps/%n/approot
wsgi-file: /srv/webapps/%n/approot/run.py
reload-os-env: true
env: LCHWEBAPP_CONF_FILE=/srv/webapps/%n/approot/conf/production.conf
env: LCHWEBAPP_CSS_CKSUM=/srv/webapps/%n/approot/build/css.cksum
env: LCHWEBAPP_JS_CKSUM=/srv/webapps/%n/approot/build/js.cksum
callable: app
And the relevant piece of the nginx config is:
location / {
uwsgi_pass 127.0.0.1:9000;
uwsgi_param UWSGI_SETENV LCHWEBAPP_LOCALE=en;
uwsgi_param UWSGI_SETENV LCHWEBAPP_SERVER_NAME=$server_name;
include uwsgi_params;
}
I'm running uwsgi version 1.2.3, nginx version 1.2.2 and Flask 0.9.
Any help on what I'm doing wrong would be very much appreciated :)
Charlie
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi