import os
from multiprocessing import Pool

cmd_list = ["uvicorn voicechat2:app --host 0.0.0.0 --port 8000 --reload",
            "uvicorn srt-server:app --host 0.0.0.0 --port 8001 --reload",
            "llama.cpp/llama-server --host 127.0.0.1 --port 8002 -m llama.cpp/Meta-Llama-3-8B-Instruct-Q4_K_M.gguf \
            -ngl 99 -c 8192",
            "uvicorn tts-server:app --host 0.0.0.0 --port 8003"]


def run(cmd):
    os.system(cmd)


if __name__ == "__main__":
    pool = Pool(4)  # 创建拥有3个进程数量的进程池
    pool.map(run, cmd_list)
    pool.close()  # 关闭进程池，不再接受新的进程
    pool.join()  # 主进程阻塞等待子进程的退出
