uwsgi安装:
yum install uwsgi-plugin-python
INI示例:
[uwsgi]
http-socket=:9090
plugin=python
wsgi-file=/home/fr-renjie.wei/selfquerydlk/index_wsgi.py
threads=2
processes=4
master=True
uid=linuxusername
route = /static/(.*)\.png static:/home/fr-renjie.wei/selfquerydlk/static/$1.png
[uwsgi]
http = 127.0.0.1:9091
chdir = /some/path//webapp
wsgi-file = /some/path/webapp/main.py
processes = 2
threads = 2
static-map = /static=/some/path/static
stats=%(chdir)/uwsgi.status
pidfile=%(chdir)/uwsgi.pid
route或static-map 就是对静态文件的指向。
守护进程运行:
uwsgi --ini config.ini -d file.log
停止服务:
uwsgi --stop uwsgi.pid
web.py侧:
app = web.application(urls, globals()).wsgifunc()
使用 uwsgi + web.py 遇到 “--no python application found, check your startup logs for errors--”
import weburls = ('/(.*)', 'hello'
)
app = web.application(urls, globals())
application = app.wsgifunc() # 这句很重要!!class hello: def GET(self, name):if not name: name = 'World'return 'Hello, ' + name + '!'if __name__ == "__main__":app.run()