问题
Is there a way to pass extra arguments to WSGIScriptAlias? For example:
WSGIScriptAlias / /foo/bar/wsgi.py
but what I want is:
WSGIScriptAlias / /foor/bar/wsgi.py baz
Edit for clarification:
I have a Django project with multiple configurations based on the environment in which it is running (cloud-based deployment). Currently, I'm loading configuration based on hostname (which I'm not overly happy with because it doesn't lend itself well to testing multiple configs on one machine without changing the system's hostname). So, another solution would be to pass in command line arguments to the application and load the config in the WSGI entry point, which is relatively trivial when running the dev server, but I'm not aware of any way to do it via Apache/WSGI.
回答1:
First up, ensure you are using daemon mode, it is preferred anyway.
- http://blog.dscpl.com.au/2012/10/why-are-you-using-embedded-mode-of.html
Then inside of your WSGI script file you can do:
import mod_wsgi
process_group = mod_wsgi.process_group
You can then use the name of the process group as a way of distinguishing which configuration.
In other words, use the name of the daemon process group you choose to use in the Apache configuration file as the distinguishing factor.
来源:https://stackoverflow.com/questions/13463687/adding-parameters-to-the-wsgi-script-alias