一 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
|
07
|
status '200
|
08
|
output 'Hello
|
09
|
response_headers 'Content-type' , 'text/plain' ),
|
10
|
( 'Content-Length' ,
|
11
|
start_response(status,
|
12
|
return [output]
|
application
是 wsgi app入口函数