mirror of https://github.com/Mai-with-u/MaiBot.git
fix(webui): check_port_available: enable SO_REUSEADDR option
Allow binding in TIME_WAIT state to reduce false positives (occurs when app restarts).pull/1511/head
parent
b63b7a7fb9
commit
e62c221192
|
|
@ -89,6 +89,8 @@ class WebUIServer:
|
|||
try:
|
||||
with socket.socket(family, socket.SOCK_STREAM) as s:
|
||||
s.settimeout(1)
|
||||
# 与 Uvicorn 一致:允许在 TIME_WAIT 状态下绑定,减少误报
|
||||
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
# 尝试绑定端口
|
||||
s.bind((test_host, self.port))
|
||||
return True
|
||||
|
|
|
|||
Loading…
Reference in New Issue