Adding parameters to the wsgi script alias

大憨熊 提交于 2019-12-23 16:53:40

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!