django啟動(dòng)uwsgi報(bào)錯(cuò)的解決方法
uwsgi介紹
uWSGI是一個(gè)Web服務(wù)器,它實(shí)現(xiàn)了WSGI協(xié)議、uwsgi、http等協(xié)議。Nginx中HttpUwsgiModule的作用是與uWSGI服務(wù)器進(jìn)行交換。
要注意 WSGI / uwsgi / uWSGI 這三個(gè)概念的區(qū)分。
- WSGI是一種Web服務(wù)器網(wǎng)關(guān)接口。它是一個(gè)Web服務(wù)器(如nginx,uWSGI等服務(wù)器)與web應(yīng)用(如用Flask框架寫的程序)通信的一種規(guī)范。
- uwsgi是一種線路協(xié)議而不是通信協(xié)議,在此常用于在uWSGI服務(wù)器與其他網(wǎng)絡(luò)服務(wù)器的數(shù)據(jù)通信。
- 而uWSGI是實(shí)現(xiàn)了uwsgi和WSGI兩種協(xié)議的Web服務(wù)器。
- uwsgi協(xié)議是一個(gè)uWSGI服務(wù)器自有的協(xié)議,它用于定義傳輸信息的類型(type of information),每一個(gè)uwsgi packet前4byte為傳輸信息類型描述,它與WSGI相比是兩樣?xùn)|西。
uwsgi性能非常高
最近在django啟動(dòng)uwsgi報(bào)錯(cuò)的時(shí)候,發(fā)現(xiàn)了一些錯(cuò)誤,下面來一起看看吧
查看uwsgi.log
*** Starting uWSGI 2.0.17 (64bit) on [Thu Apr 5 17:46:15 2018] *** compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-18) on 05 April 2018 02:08:03 os: Linux-2.6.32-642.6.2.el6.x86_64 #1 SMP Wed Oct 26 06:52:09 UTC 2016 nodename: GDJ_DEV machine: x86_64 clock source: unix detected number of CPU cores: 1 current working directory: /xxx/xxx/xxx/xxx writing pidfile to uwsgi.pid detected binary path: /xxx/xxx/.virtualenvs/h1/bin/uwsgi !!! no internal routing support, rebuild with pcre support !!! chdir() to /xxx/xxx/xxx/xxx your processes number limit is 100000 your memory page size is 4096 bytes detected max file descriptor number: 100000 lock engine: pthread robust mutexes thunder lock: disabled (you can enable it with --thunder-lock) uWSGI http bound on 172.21.0.5:8000 fd 4 uwsgi socket 0 bound to TCP address 127.0.0.1:33522 (port auto-assigned) fd 3 Python version: 3.6.4 (default, Mar 24 2018, 10:32:21) [GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] Python main interpreter initialized at 0x1ff10d0 python threads support enabled your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 416880 bytes (407 KB) for 8 cores *** Operational MODE: preforking+threaded *** failed to open python file xxx/uwsgi.ini unable to load app 0 (mountpoint='') (callable not found or import error) *** no app loaded. going in full dynamic mode *** *** uWSGI is running in multiple interpreter mode *** spawned uWSGI master process (pid: 4865) spawned uWSGI worker 1 (pid: 4866, cores: 2) spawned uWSGI worker 2 (pid: 4867, cores: 2) spawned uWSGI worker 3 (pid: 4868, cores: 2) spawned uWSGI worker 4 (pid: 4869, cores: 2) spawned uWSGI http 1 (pid: 4870) --- no python application found, check your startup logs for errors --- [pid: 4869|app: -1|req: -1/1] 118.26.10.242 () {40 vars in 777 bytes} [Thu Apr 5 17:46:31 2018] GET /user/login/ => generated 21 bytes in 0 msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
解決第一個(gè)報(bào)錯(cuò),注意操作的先后順序:
1.卸載uwsgi
pip uninstall uwsgi
#注意此時(shí)卸載,pip會(huì)有緩存留在系統(tǒng)里
2.安裝pcre支持庫
yum install pcre pcre-devel pcre-static
3.繼續(xù)安裝uwsgi,不走pip緩存
pip install uwsgi -I --no-cache-dir
#啟動(dòng)uwsgi,已經(jīng)沒有“ !!! no internal routing support, rebuild with pcre support !!! ”報(bào)錯(cuò)了
解決第二個(gè)報(bào)錯(cuò):
需要在你的uwsgi.ini文件中module指定項(xiàng)目下面的wsgi:
module=xxx.wsgi
#注:xxx為項(xiàng)目名稱,startproject那個(gè)項(xiàng)目名稱,這個(gè)錯(cuò)誤解決后,下面的訪問錯(cuò)誤自然而然的就解決了!
附:我的uwsgi.ini配置文件
[uwsgi] #socket=ip:port #使用nginx代理請求時(shí)配置,直接訪問uwsgi使用http方式 http=ip:port chdir=/xxx/xxx #項(xiàng)目根目錄的絕對路徑 wsgi-file=xxx/uwsgi.ini #項(xiàng)目目錄下的uwsgi.ini module=xxx.wsgi #指向項(xiàng)目下的wsgi模塊 processes=4 threads=2 master=True py-atuo-reload=1 env=DJANGO_SETTINGS_MODULE=xxx.settings pidfile=uwsgi.pid daemonize=uwsgi.log
總結(jié)
以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。
相關(guān)文章
關(guān)于Python3 類方法、靜態(tài)方法新解
今天小編就為大家分享一篇關(guān)于Python3 類方法、靜態(tài)方法新解,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-08-08利用Python進(jìn)行網(wǎng)絡(luò)爬蟲和數(shù)據(jù)抓取的代碼示例
在當(dāng)今數(shù)字化時(shí)代,數(shù)據(jù)是無處不在的,從市場趨勢到個(gè)人偏好,從社交媒體活動(dòng)到商業(yè)智能,數(shù)據(jù)扮演著關(guān)鍵的角色,Python提供了一套強(qiáng)大而靈活的工具,使得網(wǎng)絡(luò)爬蟲和數(shù)據(jù)抓取成為可能,本文將深入探討如何利用Python進(jìn)行網(wǎng)絡(luò)爬蟲和數(shù)據(jù)抓取,為您打開數(shù)據(jù)世界的大門2024-05-05python實(shí)現(xiàn)txt文件格式轉(zhuǎn)換為arff格式
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)txt文件格式轉(zhuǎn)換為arff格式的方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-05-05如何基于Python pygame實(shí)現(xiàn)動(dòng)畫跑馬燈
這篇文章主要介紹了如何基于Python pygame實(shí)現(xiàn)動(dòng)畫跑馬燈,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-11-11python打包pyinstall的實(shí)現(xiàn)步驟
PyInstaller可將Python代碼打包成單個(gè)可執(zhí)行文件,本文主要介紹了python打包pyinstall的實(shí)現(xiàn)步驟,具有一定的參考價(jià)值,感興趣的可以了解一下2023-10-10python Manager 之dict KeyError問題的解決
今天小編就為大家分享一篇python Manager 之dict KeyError問題的解決,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12