fix: ocg_router single-threaded HTTPServer blocks all requests on large body — switch to ThreadingHTTPServer
This commit is contained in:
@@ -21,7 +21,7 @@ OpenAI 兼容代理,背后池化 6 个 OpenCode Go API key。
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os, sys, json, time, logging, threading
|
import os, sys, json, time, logging, threading
|
||||||
from http.server import HTTPServer, BaseHTTPRequestHandler
|
from http.server import ThreadingHTTPServer, BaseHTTPRequestHandler
|
||||||
from urllib.request import Request, urlopen, HTTPError
|
from urllib.request import Request, urlopen, HTTPError
|
||||||
from urllib.error import URLError
|
from urllib.error import URLError
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
@@ -651,8 +651,8 @@ def main():
|
|||||||
refresh_thread = threading.Thread(target=_bg_refresh, name="ocg_router_refresh", daemon=True)
|
refresh_thread = threading.Thread(target=_bg_refresh, name="ocg_router_refresh", daemon=True)
|
||||||
refresh_thread.start()
|
refresh_thread.start()
|
||||||
|
|
||||||
# 启动 HTTP 服务
|
# 启动 HTTP 服务(ThreadingHTTPServer — 多线程,避免大请求阻塞 /api/status 等监控端点)
|
||||||
server = HTTPServer((LISTEN_HOST, LISTEN_PORT), RouterHandler)
|
server = ThreadingHTTPServer((LISTEN_HOST, LISTEN_PORT), RouterHandler)
|
||||||
log.info("ocg_router 启动 → http://%s:%d", LISTEN_HOST, LISTEN_PORT)
|
log.info("ocg_router 启动 → http://%s:%d", LISTEN_HOST, LISTEN_PORT)
|
||||||
log.info("keys loaded: %d (%d healthy)", len(_keys),
|
log.info("keys loaded: %d (%d healthy)", len(_keys),
|
||||||
sum(1 for k in _keys if _key_health_score(k["key_id"]) < 888))
|
sum(1 for k in _keys if _key_health_score(k["key_id"]) < 888))
|
||||||
|
|||||||
Reference in New Issue
Block a user