Apache:使用mod_wsgi时自动reload代码
来源:互联网 发布:淘宝分销代理好做吗 编辑:程序博客网 时间:2024/06/05 05:14
Delegation To Daemon Process
By default any WSGI application will run in what is called embedded mode. That is, the application will be hosted within the Apache worker processes used to handle normal static file requests.
When embedded mode is used, whenever you make changes to your WSGI application code you would generally have to restart the whole Apache web server in order for changes to be picked up. This can be inconvenient, especially if the web server is a shared resource hosting other web applications at the same time, or you don’t have root access to be able to restart the server and rely on someone else to restart it.
On UNIX systems when running Apache 2.X, an option which exists with mod_wsgi and that avoids the need to restart the whole Apache web server when code changes are made, is to use what is called daemon mode.
In daemon mode a set of processes is created for hosting a WSGI application, with any requests for that WSGI application automatically being routed to those processes for handling.
When code changes are made and it is desired that the daemon processes for the WSGI application be restarted, all that is required is to mark the WSGI application script file as modified by using the ‘touch’ command.
To make use of daemon mode for WSGI applications hosted within a specific site, the WSGIDaemonProcess and WSGIProcessGroup directives would need to be defined. For example, to setup a daemon process group containing two multithreaded process one could use:
WSGIDaemonProcess example.com processes=2 threads=15WSGIProcessGroup example.com
A complete virtual host configuration for this type of setup would therefore be something like:
<VirtualHost *:80> ServerName www.example.com ServerAlias example.com ServerAdmin webmaster@example.com DocumentRoot /usr/local/www/documents Alias /robots.txt /usr/local/www/documents/robots.txt Alias /favicon.ico /usr/local/www/documents/favicon.ico Alias /media/ /usr/local/www/documents/media/ <Directory /usr/local/www/documents> Order allow,deny Allow from all </Directory> WSGIDaemonProcess example.com processes=2 threads=15 display-name=%{GROUP} WSGIProcessGroup example.com WSGIScriptAlias / /usr/local/www/wsgi-scripts/myapp.wsgi <Directory /usr/local/www/wsgi-scripts> Order allow,deny Allow from all </Directory></VirtualHost>
After appropriate changes have been made Apache will need to be restarted. For this example, the URL ‘http://www.example.com/‘ would then be used to access the the WSGI application.
Note that you obviously should substitute the paths and hostname with values appropriate for your system.
As mentioned previously, the daemon processes will be shutdown and restarted automatically if the WSGI application script file is modified.
For the sample application presented in this document the whole application is in that file. For more complicated applications the WSGI application script file will be merely an entry point to an application being imported from other Python modules or packages. In this later case, although no change may be required to the WSGI application script file itself, it can still be touched to trigger restarting of the daemon processes in the event that any code in the separate modules or packages is changed.
Note that only requests for the WSGI application are handled within the context of the daemon processes. Any requests for static files are still handled within the Apache worker processes.
- Apache:使用mod_wsgi时自动reload代码
- Apache使用mod_wsgi安装Trac
- 使用Apache + mod_wsgi部署webpy应用
- 使用Apache + mod_wsgi部署webpy应用
- 用mod_wsgi在apache中使用django
- 使用mod_wsgi将django部署到apache
- apache下 使用svn自动部署代码
- 使用Apache+mod_wsgi部署webpy等python程序
- Windows环境下使用Apache+mod_wsgi部署webpy
- 【Django】 Windows下使用Apache+mod_wsgi部署Django
- 使用Apache与mod_wsgi部署Django应用到服务器
- bottle+apache+mod_wsgi
- 让apache支持 mod_wsgi
- apache +mod_wsgi + django deploying
- django apache mod_wsgi配置
- apache 2.4配置mod_wsgi
- apache+mod_wsgi应用WSGI
- Apache + Flask + mod_wsgi部署
- 42. Trapping Rain Water
- 集群Session的解决方案
- TOJ 1455.Ultra-QuickSort(分治经典题目)
- PHP登陆Session验证
- 【奔跑的FPGA】part two ip核仿真遇到的问题以及解决办法
- Apache:使用mod_wsgi时自动reload代码
- 回文树——BZOJ 2160: 拉拉队排练
- Android 4.4 Kitkat 使能有线网络 Ethernet
- 7月第三周——任务
- 非线性分类器---非线性转换解决非线性分类问题
- PAT-B 1018.锤子剪刀布
- Ceph高级工具介绍之ceph-kvstore-tool的使用
- 一起来点React Native
- Java之Socket上的Read操作阻塞问题