From 33eeba687393132750ebbb0d4b235926f82ad23b Mon Sep 17 00:00:00 2001 From: fanpt <320622572@qq.com> Date: Wed, 27 Aug 2025 11:19:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=8A=B6=E6=80=81=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=200-=E6=9C=AA=E5=90=AF=E5=8A=A8=EF=BC=8C1-=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E4=B8=AD=EF=BC=8C2-=E5=B7=B2=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C3-=E5=90=AF=E5=8A=A8=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api_v2.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/api_v2.py b/api_v2.py index 9abfcba..451a48c 100644 --- a/api_v2.py +++ b/api_v2.py @@ -654,7 +654,7 @@ async def set_sovits_weights(weights_path: str = None): if __name__ == "__main__": try: - + # 启动服务器中(状态修改为1) set_status(db_path, 1) if host == "None": # 在调用时使用 -a None 参数,可以让api监听双栈 @@ -664,14 +664,19 @@ if __name__ == "__main__": if not check_port(port): print(f"端口 {port} 已被占用,无法启动服务。") - set_status(db_path, 3) # 更新状态为启动失败 + # 端口被占用,启动服务器失败(状态修改为3) + set_status(db_path, 3) exit(1) + + # 启动服务器成功(状态修改为2) set_status(db_path, 2) + # 再启动服务器(这是一个阻塞调用) uvicorn.run(app=APP, host=host, port=port, workers=1) except Exception: traceback.print_exc() + # 启动服务器失败(状态修改为3) set_status(db_path, 3) os.kill(os.getpid(), signal.SIGTERM) exit(0)