Skip to content

Commit 14bb4b5

Browse files
ZhangYulonggchang-wenbin
authored andcommitted
Update deploy.py (PaddlePaddle#4850)
1 parent b1b6a0b commit 14bb4b5

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/ce/deploy/deploy.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
import yaml
1414
from flask import Flask, Response, jsonify, request
1515

16+
current_dir = os.path.dirname(os.path.abspath(__file__))
17+
tests_dir = os.path.abspath(os.path.join(current_dir, "..", ".."))
18+
19+
sys.path.insert(0, tests_dir)
20+
21+
from e2e.utils.serving_utils import (
22+
FD_API_PORT,
23+
FD_CACHE_QUEUE_PORT,
24+
FD_ENGINE_QUEUE_PORT,
25+
FD_METRICS_PORT,
26+
clean_ports,
27+
)
28+
1629
app = Flask(__name__)
1730

1831

@@ -56,10 +69,6 @@ def get_available_port(env_key: str, default_start: int):
5669
LOG_FILE = "server.log"
5770
base_port = get_base_port()
5871
FLASK_PORT = get_available_port("FLASK_PORT", base_port + 1)
59-
FD_API_PORT = get_available_port("FD_API_PORT", FLASK_PORT + 1)
60-
FD_ENGINE_QUEUE_PORT = get_available_port("FD_ENGINE_QUEUE_PORT", FD_API_PORT + 1)
61-
FD_METRICS_PORT = get_available_port("FD_METRICS_PORT", FD_ENGINE_QUEUE_PORT + 1)
62-
FD_CACHE_QUEUE_PORT = get_available_port("FD_CACHE_QUEUE_PORT", FD_METRICS_PORT + 1)
6372
DEFAULT_PARAMS = {
6473
"--port": FD_API_PORT,
6574
"--engine-worker-queue-port": FD_ENGINE_QUEUE_PORT,
@@ -176,6 +185,7 @@ def stop_server(signum=None, frame=None):
176185
os.remove("gemm_profiles.json")
177186

178187
try:
188+
clean_ports()
179189
# 终止进程组(包括所有子进程)
180190
os.killpg(os.getpgid(pid_port["PID"]), signal.SIGTERM)
181191
except Exception as e:

0 commit comments

Comments
 (0)