以http形式啟動uwsgi服務


uwsgi yourfile.ini # 配置文件

[uwsgi]

http = 127.0.0.1:3106

socket = 127.0.0.1:3006

chdir = /www/studentapitest/zhishidian

pythonpath = /www/studentapitest/

env = DJANGO_SETTINGS_MODULE=zhishidian.linux_settings

module = django.core.handlers.wsgi:WSGIHandler()

workers = 4

max-request = 2000

master = true

harakiri = 30

pidfile = /www/config/studentapitest.tbkt.cn.pid

touch-reload = /www/config/studentapitest.tbkt.cn.reload.txt

daemonize = /www/logs/studentapitest.tbkt.cn.uwsgi.log

 

加入http參數后就可以以http形式訪問,配置好並啟動uwsgi服務后,在瀏覽器中輸入http://127.0.0.1:3106就可以直接訪問了,這樣配置的優點是可以用程序直接訪問,3006和3106兩個端口是在一個進程里面運行

如下python代碼片段

import urllib2

res = urllib2.urlopen("http://127.0.0.1:3106/login/")

print res.read()

 

nginx 則可以socket形式訪問

location / {

    uwsgi_pass 127.0.0.1:3106;

    include uwsgi_params;

}

 

更多用法參考官方文檔

http://uwsgi-docs.readthedocs.org/en/latest/WSGIquickstart.html#deploying-django

http://uwsgi-docs.readthedocs.org/en/latest/HTTP.html

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM