mirror of
https://github.com/yuruotong1/autoMate.git
synced 2025-12-26 05:16:21 +08:00
更新等待服务启动
This commit is contained in:
parent
2adb839295
commit
b3d66c669c
16
main.py
16
main.py
@ -6,15 +6,27 @@ from gradio_ui import app
|
||||
from util import download_weights
|
||||
import time
|
||||
def run():
|
||||
# 启动 server.py 子进程
|
||||
# 启动 server.py 子进程,并捕获其输出
|
||||
server_process = subprocess.Popen(
|
||||
["python", "./server.py"],
|
||||
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
|
||||
stdout=subprocess.PIPE, # 捕获标准输出
|
||||
stderr=subprocess.PIPE,
|
||||
creationflags=subprocess.CREATE_NEW_PROCESS_GROUP,
|
||||
text=True
|
||||
)
|
||||
|
||||
try:
|
||||
# 下载权重文件
|
||||
download_weights.download()
|
||||
# 启动 Gradio UI
|
||||
# 等待 server_process 打印出 "Started server process"
|
||||
while True:
|
||||
output = server_process.stdout.readline()
|
||||
if "Started server process" in output:
|
||||
print("Omniparseer服务启动成功...")
|
||||
break
|
||||
if server_process.poll() is not None:
|
||||
raise RuntimeError("Server process terminated unexpectedly")
|
||||
app.run()
|
||||
finally:
|
||||
# 确保在主进程退出时终止子进程
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user