我想設置一個uwsgi託管的應用程序,使我得到優雅與uwsgi重裝--reload但我明顯失敗。這裏是我的測試uwsgi設置:uwsgi --reload拒絕傳入連接
[admin2-prod]
http = 127.0.0.1:9090
pyargv = $* --db=prod --base-path=/admin/
max-requests = 3
listen=1000
http-keepalive = 1
pidfile2 =admin.pid
add-header=Connection: keep-alive
workers = 1
master = true
chdir = .
plugins = python,http,router_static,router_uwsgi,router_http
buffer-size = 8192
pythonpath = admin2
file = admin2/app.py
static-map=/admin/static/=admin2/static/
static-map=/admin/v3/build/=admin2/client/build/
disable-logging = false
http-timeout = 100
(請注意,我跑的sysctl net.core.somaxconn = 1000)之前
這裏是我的測試Python腳本:
import httplib
connection = httplib.HTTPConnection('127.0.0.1', 9090)
connection.connect()
for i in range(0, 1000):
print 'sending... ', i
try:
connection.request('GET', '/x', '', {'Connection' : ' keep-alive'})
response = connection.getresponse()
d = response.read()
print ' ', response.status
except:
connection = httplib.HTTPConnection('127.0.0.1', 9090)
connection.connect()
上述客戶端在--reload期間失敗:
sending... 920
Traceback (most recent call last):
File "./test.py", line 15, in <module>
connection.connect()
File "/usr/lib64/python2.7/httplib.py", line 836, in connect
self.timeout, self.source_address)
File "/usr/lib64/python2.7/socket.py", line 575, in create_connection
raise err
socket.error: [Errno 111] Connection refused
從tcpdump看來,它看起來像uwsgi確實接受這恰好在所述--reload,客戶端被髮送GET第二傳入TCP請求時,服務器是TCP確認序號,但在連接最後由服務器發送回HTTP響應之前RSTed。那麼,我錯過了什麼才能讓服務器對這個傳入連接進行排隊,直到它準備好處理它並獲得真正的優雅重新加載?
很明顯,在現實世界中,你不能重寫所有連接到你的服務器的http客戶端的代碼。我的問題是:我可以做些什麼來獲得任意客戶端的優雅重載(無失敗)。 – mathieu
@mathieu - 通過異常退出,如果服務器不可用任意的客戶有邏輯錯誤的一些明顯:)但是,如果你是認真的 - ** **代理(檢查答案更新)或寫一些包裝過程中,將可能處理不當的情況或向客戶作者發送補丁... – ndpu