From 5c19dcab85416850ba07bcd67ceef2448896c0b2 Mon Sep 17 00:00:00 2001 From: Zhang Yulong <35552275+ZhangYulongg@users.noreply.github.com> Date: Thu, 6 Nov 2025 14:42:51 +0800 Subject: [PATCH] Update deploy.py --- tests/ce/deploy/deploy.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tests/ce/deploy/deploy.py b/tests/ce/deploy/deploy.py index 876435f6a5c..be6a4f0bf7d 100644 --- a/tests/ce/deploy/deploy.py +++ b/tests/ce/deploy/deploy.py @@ -13,6 +13,19 @@ import yaml from flask import Flask, Response, jsonify, request +current_dir = os.path.dirname(os.path.abspath(__file__)) +tests_dir = os.path.abspath(os.path.join(current_dir, "..", "..")) + +sys.path.insert(0, tests_dir) + +from e2e.utils.serving_utils import ( + FD_API_PORT, + FD_CACHE_QUEUE_PORT, + FD_ENGINE_QUEUE_PORT, + FD_METRICS_PORT, + clean_ports, +) + app = Flask(__name__) @@ -56,10 +69,6 @@ def get_available_port(env_key: str, default_start: int): LOG_FILE = "server.log" base_port = get_base_port() FLASK_PORT = get_available_port("FLASK_PORT", base_port + 1) -FD_API_PORT = get_available_port("FD_API_PORT", FLASK_PORT + 1) -FD_ENGINE_QUEUE_PORT = get_available_port("FD_ENGINE_QUEUE_PORT", FD_API_PORT + 1) -FD_METRICS_PORT = get_available_port("FD_METRICS_PORT", FD_ENGINE_QUEUE_PORT + 1) -FD_CACHE_QUEUE_PORT = get_available_port("FD_CACHE_QUEUE_PORT", FD_METRICS_PORT + 1) DEFAULT_PARAMS = { "--port": FD_API_PORT, "--engine-worker-queue-port": FD_ENGINE_QUEUE_PORT, @@ -176,6 +185,7 @@ def stop_server(signum=None, frame=None): os.remove("gemm_profiles.json") try: + clean_ports() # 终止进程组(包括所有子进程) os.killpg(os.getpgid(pid_port["PID"]), signal.SIGTERM) except Exception as e: