mirror of https://github.com/jackwener/wx-cli.git
fix: 清理调试代码 + 提升服务稳定性
- 移除 _debug_log、signal handler、atexit 等调试代码 - 添加 allow_reuse_address 防止重启端口占用 - warmup 线程加外层异常捕获防止静默崩溃 - 恢复启动自动打开浏览器 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>feat/daemon-cli
parent
73598751a0
commit
3b4b811cc3
|
|
@ -1866,6 +1866,7 @@ class Handler(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
class ThreadedServer(ThreadingMixIn, HTTPServer):
|
class ThreadedServer(ThreadingMixIn, HTTPServer):
|
||||||
daemon_threads = True
|
daemon_threads = True
|
||||||
|
allow_reuse_address = True
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
@ -1907,19 +1908,22 @@ def main():
|
||||||
|
|
||||||
# 后台预热所有 message DB(图片/emoji 解密必需)
|
# 后台预热所有 message DB(图片/emoji 解密必需)
|
||||||
def _warmup():
|
def _warmup():
|
||||||
t0 = time.perf_counter()
|
try:
|
||||||
warmup_keys = ["message\\message_resource.db"]
|
t0 = time.perf_counter()
|
||||||
for i in range(5):
|
warmup_keys = ["message\\message_resource.db"]
|
||||||
k = f"message\\message_{i}.db"
|
for i in range(5):
|
||||||
if k in keys:
|
k = f"message\\message_{i}.db"
|
||||||
warmup_keys.append(k)
|
if k in keys:
|
||||||
for k in warmup_keys:
|
warmup_keys.append(k)
|
||||||
t1 = time.perf_counter()
|
for k in warmup_keys:
|
||||||
try:
|
t1 = time.perf_counter()
|
||||||
db_cache.get(k)
|
try:
|
||||||
print(f"[warmup] {k} {(time.perf_counter()-t1)*1000:.0f}ms", flush=True)
|
db_cache.get(k)
|
||||||
except Exception as e:
|
print(f"[warmup] {k} {(time.perf_counter()-t1)*1000:.0f}ms", flush=True)
|
||||||
print(f"[warmup] {k} 失败: {e}", flush=True)
|
except Exception as e:
|
||||||
|
print(f"[warmup] {k} 失败: {e}", flush=True)
|
||||||
|
except Exception as e:
|
||||||
|
print(f"[warmup] 异常: {e}", flush=True)
|
||||||
# 构建 emoji 映射(独立解密,不走 cache)
|
# 构建 emoji 映射(独立解密,不走 cache)
|
||||||
_build_emoji_lookup(keys)
|
_build_emoji_lookup(keys)
|
||||||
print(f"[warmup] 全部完成 {(time.perf_counter()-t0)*1000:.0f}ms", flush=True)
|
print(f"[warmup] 全部完成 {(time.perf_counter()-t0)*1000:.0f}ms", flush=True)
|
||||||
|
|
@ -1934,7 +1938,7 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.system(f'cmd.exe /c start http://localhost:{PORT}')
|
os.system(f'cmd.exe /c start http://localhost:{PORT}')
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue