您的位置:首页 > 其它

UWSGI配置文件---ini和xml示例

2014-01-07 13:36 211 查看

一 conf.ini文件:

[uwsgi]

http = $(HOSTNAME):9033

http-keepalive = 1

pythonpath = ../

module = service

master = 1

processes = 8

daemonize = logs/uwsgi.log

disable-logging = 1

buffer-size = 16384

harakiri = 5

pidfile = uwsgi.pid

stats = $(HOSTNAME):1733

运行:uwsgi --ini conf.ini

二 conf.xml文件

<uwsgi>

<!--

<cluster>225.1.1.1:3333</cluster>

<socket>192.168.60.*:3031</socket>

<http>127.0.0.1:3031</http>

-->

<http>192.168.3.40:9033</http>

<pythonpath>../</pythonpath>

<module>service</module>

<master>1</master>

<processes>8</processes>

<disable-logging />

<daemonize>logs/uwsgi_bfdds.log</daemonize>

<buffer-size>16384</buffer-size>

<harakiri>30</harakiri>

<pidfile>uwsgi_bfdds.pid</pidfile>

<stats>192.168.3.40:1716</stats>

</uwsgi>

1 !--开头的是注释掉的。

2 接收的数据有两种方式,socket和http方式。分别写成:

<http>ip:port</http>

<socket>ip:por</socket>

3 <module>service</module> 是应用文件,例子中对应的文件service.py,用来处理请求

4 <pythonpath>../</pythonpath> 是应用文件所在的路径,也就是service.py所在路径。

三 应用内容

service.py脚本:

01
#!/usr/bin/python
02
import
os
03
import
sys
06
def
 application(environ,start_response):
07
status
 =
'200
 OK'
08
output
 =
'Hello
 World!'
09
response_headers
 = [(
'Content-type'
,
'text/plain'
),
10
(
'Content-Length'
,
 str(len(output)))]
11
start_response(status,
 response_headers)
12
return
[output]
application
是 wsgi app入口函数
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: