何时使用守护进程组时的Apache2执行.wsgi脚本? [英] When does apache2 execute a .wsgi script when using daemon process groups?

查看:153
本文介绍了何时使用守护进程组时的Apache2执行.wsgi脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给出如下简单的apache2的conf的时候会django.wsgi执行?它的看起来的喜欢它仅执行第一次查询到达,再也没有。我期待它在Apache启动时执行,然后永远不再。任何人都可以提供一些线索就如何工作的?

  WSGIDaemonProcess网站-1用户=用户1组=用户1线程= 25
WSGIProcessGroup网站1WSGIScriptAlias​​ / /usr/local/django/mysite/apache/django.wsgi<目录/ usr /本地/ Django的/ mysite的/阿帕奇>
为了否认,允许
所有允许
< /目录>


解决方案

WSGI脚本文件在技术上不执行,但都是进口的。因此,他们都喜欢在Python任何其它模块,它们被装一次。在这种情况下,当请求首先到达,并且需要由WSGI脚本文件映射到的应用程序时发生

一旦加载,WSGI应用对象是每个请求执行一次。

有一些例外是,就在某些情况下WSGI脚本文件重装。对于读的解释:

现在尽管它装在第一请求要求它,您可以强制将其使用的WSGIImportScript指令过程启动时加载的:

或使用过程组和应用组选项与WSGIScriptAlias​​指令在一起。后者在3.O的mod_wsgi介绍。

Given a simple apache2 conf as below, when will django.wsgi execute? It seems like it executes only the first time a query arrives and never again. I was expecting it to execute on apache startup and then never again. Can anybody shed some light on how this works?

WSGIDaemonProcess site-1 user=user-1 group=user-1 threads=25
WSGIProcessGroup site-1

WSGIScriptAlias / /usr/local/django/mysite/apache/django.wsgi

<Directory /usr/local/django/mysite/apache>
Order deny,allow
Allow from all
</Directory>

解决方案

WSGI script files are technically not executed but are imported. Thus they are like any other module in Python, they are loaded once. In this case it occurs when the request first arrives and the application mapped by that WSGI script file is required.

Once loaded, the WSGI application object is executed once per request.

There are some exceptions to that as far as reloading of the WSGI script file in certain circumstances. For an explanation of that read:

Now although it is loaded the first a request requires it to be, you can force that it be loaded on process startup using the WSGIImportScript directive:

or the use of process-group and application-group options together with the WSGIScriptAlias directive. The latter was introduced in mod_wsgi 3.o.

这篇关于何时使用守护进程组时的Apache2执行.wsgi脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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