fix: 使用前置网关处理静态文件来加速,尝试解决延迟的问题
This commit is contained in:
parent
b34215560c
commit
4ae3774a0e
@ -3,6 +3,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import uvicorn
|
import uvicorn
|
||||||
|
|
||||||
@ -142,15 +143,6 @@ def main():
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Execption {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():
|
def run_server():
|
||||||
xiaomusic = XiaoMusic(config)
|
xiaomusic = XiaoMusic(config)
|
||||||
HttpInit(xiaomusic)
|
HttpInit(xiaomusic)
|
||||||
@ -161,10 +153,6 @@ def main():
|
|||||||
log_config=LOGGING_CONFIG,
|
log_config=LOGGING_CONFIG,
|
||||||
)
|
)
|
||||||
|
|
||||||
# thread = threading.Thread(target=run_server)
|
|
||||||
# thread.start()
|
|
||||||
# run_gate()
|
|
||||||
|
|
||||||
command = [
|
command = [
|
||||||
"uvicorn",
|
"uvicorn",
|
||||||
"xiaomusic.gate:app",
|
"xiaomusic.gate:app",
|
||||||
@ -176,11 +164,11 @@ def main():
|
|||||||
str(config.port),
|
str(config.port),
|
||||||
]
|
]
|
||||||
|
|
||||||
# process = subprocess.Popen(command)
|
process = subprocess.Popen(command)
|
||||||
def signal_handler(sig, frame):
|
def signal_handler(sig, frame):
|
||||||
print("主进程收到退出信号,准备退出...")
|
print("主进程收到退出信号,准备退出...")
|
||||||
# process.terminate() # 终止子进程
|
process.terminate() # 终止子进程
|
||||||
# process.wait() # 等待子进程退出
|
process.wait() # 等待子进程退出
|
||||||
print("子进程已退出")
|
print("子进程已退出")
|
||||||
os._exit(0) # 退出主进程
|
os._exit(0) # 退出主进程
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user