From 4ae3774a0ed41e0f7a08d1f44b8d5e48271a062c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B6=B5=E6=9B=A6?= Date: Tue, 30 Jul 2024 11:49:29 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BD=BF=E7=94=A8=E5=89=8D=E7=BD=AE?= =?UTF-8?q?=E7=BD=91=E5=85=B3=E5=A4=84=E7=90=86=E9=9D=99=E6=80=81=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E6=9D=A5=E5=8A=A0=E9=80=9F=EF=BC=8C=E5=B0=9D=E8=AF=95?= =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=BB=B6=E8=BF=9F=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- xiaomusic/cli.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/xiaomusic/cli.py b/xiaomusic/cli.py index ae86161..14887a3 100644 --- a/xiaomusic/cli.py +++ b/xiaomusic/cli.py @@ -3,6 +3,7 @@ import argparse import json import os import signal +import subprocess import uvicorn @@ -142,15 +143,6 @@ def main(): except Exception as e: print(f"Execption {e}") - def run_gate(): - uvicorn.run( - "gate:app", - host="0.0.0.0", - port=config.port, - log_config=LOGGING_CONFIG, - workers=2, - ) - def run_server(): xiaomusic = XiaoMusic(config) HttpInit(xiaomusic) @@ -161,10 +153,6 @@ def main(): log_config=LOGGING_CONFIG, ) - # thread = threading.Thread(target=run_server) - # thread.start() - # run_gate() - command = [ "uvicorn", "xiaomusic.gate:app", @@ -176,11 +164,11 @@ def main(): str(config.port), ] - # process = subprocess.Popen(command) + process = subprocess.Popen(command) def signal_handler(sig, frame): print("主进程收到退出信号,准备退出...") - # process.terminate() # 终止子进程 - # process.wait() # 等待子进程退出 + process.terminate() # 终止子进程 + process.wait() # 等待子进程退出 print("子进程已退出") os._exit(0) # 退出主进程