在測試環境使用uwsgi啟動flask未成功
正常報錯信息:
*** Starting uWSGI 2.0.13.1 (64bit) on [Fri Sep 23 09:27:47 2016] ***
compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-4) on 22 September 2016 11:24:15
os: Linux-2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013
nodename: localhost.localdomain
machine: x86_64
clock source: unix
detected number of CPU cores: 1
current working directory: /home/sae/pengyusong/saeServers/tcc
writing pidfile to ./tcc.pid
detected binary path: /home/sae/tools/python2.7.12/bin/uwsgi
!!! no internal routing support, rebuild with pcre support !!!
your processes number limit is 1024
your memory page size is 4096 bytes
detected max file descriptor number: 100000
lock engine: pthread robust mutexes
thunder lock: enabled
Listen queue size is greater than the system max net.core.somaxconn (128).
VACUUM: pidfile removed.
unlink(): No such file or directory [core/uwsgi.c line 1634]
從這里看不出什么問題,在網上找到一種方法可以看到具體錯誤信息如下:使用 strace -f [ -o trace.log ] uwsgi --ini uwsgi.ini
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 open("/proc/sys/net/core/somaxconn", O_RDONLY) = 4 read(4, "128\n", 16) = 4 close(4) = 0 write(2, "Listen queue size is greater tha"..., 75Listen queue size is greater than the system max net.core.somaxconn (128). ) = 75 chdir("/home/sae/pengyusong/saeServers/tcc") = 0 unlink("./tcc.pid") = 0 write(2, "VACUUM: pidfile removed.\n", 25VACUUM: pidfile removed. ) = 25 unlink("/tmp/stats_tcc.socket") = -1 ENOENT (No such file or directory) write(2, "unlink(): No such file or direct"..., 61unlink(): No such file or directory [core/uwsgi.c line 1634] ) = 61 exit_group(1)
從上述錯誤看到,可能是因為沒有這個文件導致的出錯,注意我說的是“可能”,因為實際上不是,這個可能就是一個檢查,沒有就會創建,真正的原因沒打印出來。
找了半天,沒辦法,與生產環境上做對比,啟動過程中一個輸出引起了我的注意:
Listen queue size is greater than the system max net.core.somaxconn (128).
這句話說的是系統的這個參數設置為128,但是我的uwsgi配置的比較大,我自以為是的認為這個應該沒關系,反正是測試環境,大不了就按照128限制來吧
沒有辦法,最后嘗試改了以下這個參數,然后再次啟動,奇跡般的啟動成功了,成功了,了。。。。
計算機的世界套路太深,有時候不按常理出牌,也是因為自己對uwsgi不熟導致的
WTF。。。