uwsgi

殺死進(jìn)程

sudo pkill -f uwsgi -9


啟動(dòng)

uwsgi --ini uwsgi.ini


優(yōu)雅地重啟

# using kill to send the signal
kill -HUP `cat /tmp/project-master.pid`
# or the convenience option --reload
uwsgi --reload /tmp/project-master.pid
# or if uwsgi was started with touch-reload=/tmp/somefile
touch /tmp/somefile

停止服務(wù)器

如果出于某些原因,你讓uWSGI進(jìn)程在前臺(tái)運(yùn)行,那么使用CTRL+C就可以殺死它了。
在處理后臺(tái)進(jìn)程時(shí),你將需要再次使用master pidfile。SIGINT信號(hào)將會(huì)殺死uWSGI.

kill -INT `cat /tmp/project-master.pid`
# or for convenience...
uwsgi --stop /tmp/project-master.pid

讀取stats

uwsgi --connect-and-read 0.0.0.0:XXX

uwsgi啟動(dòng)報(bào)錯(cuò) chdir(): No such file or directory [core/uwsgi.c line 2591]

檢查ini中chdir后的路徑是否包含有空格,是的話將空格刪除


使用uwsgi報(bào)錯(cuò)uwsgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file

conda install -c conda-forge libiconv

參數(shù)詳解

socket : 地址和端口號(hào),例如:socket = 127.0.0.1:50000

processes : 開啟的進(jìn)程數(shù)量

workers : 開啟的進(jìn)程數(shù)量,等同于processes(官網(wǎng)的說法是spawn the specified number of workers / processes)

chdir : 指定運(yùn)行目錄(chdir to specified directory before apps loading)

wsgi-file : 載入wsgi-file(load .wsgi file)

stats : 在指定的地址上,開啟狀態(tài)服務(wù)(enable the stats server on the specified address)

threads : 運(yùn)行線程。由于GIL的存在,我覺得這個(gè)真心沒啥用。(run each worker in prethreaded mode with the specified number of threads)

master : 允許主進(jìn)程存在(enable master process)

daemonize : 使進(jìn)程在后臺(tái)運(yùn)行,并將日志打到指定的日志文件或者udp服務(wù)器(daemonize uWSGI)。實(shí)際上最常用的,還是把運(yùn)行記錄輸出到一個(gè)本地文件上。

log-maxsize :以固定的文件大小(單位KB),切割日志文件。 例如:log-maxsize = 50000000 就是50M一個(gè)日志文件。

pidfile : 指定pid文件的位置,記錄主進(jìn)程的pid號(hào)。

vacuum : 當(dāng)服務(wù)器退出的時(shí)候自動(dòng)清理環(huán)境,刪除unix socket文件和pid文件(try to remove all of the generated file/sockets)

disable-logging : 不記錄請(qǐng)求信息的日志。只記錄錯(cuò)誤以及uWSGI內(nèi)部消息到日志中。如果不開啟這項(xiàng),那么你的日志中會(huì)大量出現(xiàn)這種記錄:

[pid: 347|app: 0|req: 106/367] 117.116.122.172 () {52 vars in 961 bytes} [Thu Jul 7 19:20:56 2016] POST /post => generated 65 bytes in 6 msecs (HTTP/1.1 200) 2 headers in 88 bytes (1 switches on core 0)

log-maxsize: 日志大小,當(dāng)大于這個(gè)大小會(huì)進(jìn)行切分 (Byte)

log-truncate: 當(dāng)啟動(dòng)時(shí)切分日志


設(shè)置python的系統(tǒng)參數(shù)(sys.argv)

--pyargv "one two three"

該配置會(huì)將sys.argv 設(shè)為('one','two','three')。


只記錄啟動(dòng)日志, 不記錄request logging

disable-logging = true
logto = /tmp/test_card.log
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容