From fa56d06e0c79d7fe6a309b63a46f094057bc373c Mon Sep 17 00:00:00 2001 From: CGD <3030332422@qq.com> Date: Wed, 7 May 2025 16:17:50 +0800 Subject: [PATCH] =?UTF-8?q?update=EF=BC=9A=E4=BC=98=E5=8C=96=E9=87=8D?= =?UTF-8?q?=E5=90=AF=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main/xiaozhi-server/core/connection.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main/xiaozhi-server/core/connection.py b/main/xiaozhi-server/core/connection.py index 8a3fea26..603ed7ae 100644 --- a/main/xiaozhi-server/core/connection.py +++ b/main/xiaozhi-server/core/connection.py @@ -1,6 +1,7 @@ import os import copy import json +import subprocess import sys import uuid import time @@ -252,8 +253,14 @@ class ConnectionHandler: """实际执行重启的方法""" time.sleep(1) self.logger.bind(tag=TAG).info("执行服务器重启...") - python = sys.executable - os.execl(python, python, *sys.argv) + subprocess.Popen( + [sys.executable, "app.py"], + stdin=sys.stdin, + stdout=sys.stdout, + stderr=sys.stderr, + start_new_session=True + ) + os._exit(0) # 使用线程执行重启避免阻塞事件循环 threading.Thread(target=restart_server, daemon=True).start()