添加参数到WSGI脚本别名 [英] Adding parameters to the wsgi script alias

查看:326
本文介绍了添加参数到WSGI脚本别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法来额外的参数传递给WSGIScriptAlias​​?例如:

Is there a way to pass extra arguments to WSGIScriptAlias? For example:

WSGIScriptAlias​​ / /foo/bar/wsgi.py ,但我想要的是:

WSGIScriptAlias​​ / /foor/bar/wsgi.py巴兹

修改澄清

我根据运行它(基于云的部署)的环境中具有多个配置一个Django项目。目前,我基于主机加载配置(我不是,因为它并不太适合在一台机器上测试多个CONFIGS不改变系统的主机名不太满意)。因此,另一种解决方案是在命令行参数传递给应用程序并加载在WSGI切入点,运行开发服务器时,这是比较琐碎的配置,但我不知道任何方式通过Apache办呢/ WSGI。

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.

推荐答案

一起来,确保您使用的是守护进程模式,这是无论如何pferred $ P $。

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

那么你的WSGI脚本文件里面你可以这样做:

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.

在换句话说,使用您选择的Apache配置文件作为区别因素中使用的守护进程组的名称。

In other words, use the name of the daemon process group you choose to use in the Apache configuration file as the distinguishing factor.

这篇关于添加参数到WSGI脚本别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆