MCPcopy Create free account
hub / github.com/PaddlePaddle/FastDeploy / is_server_running

Function is_server_running

tests/ce/deploy/deploy.py:122–141  ·  view source on GitHub ↗

检查服务是否正在运行

()

Source from the content-addressed store, hash-verified

120
121
122def is_server_running():
123 """检查服务是否正在运行"""
124 pid_port = get_server_pid()
125 if pid_port is None:
126 return False, {"status": "Server not running..."}
127
128 _, port = pid_port["PID"], pid_port["PORT"]
129 health_check_endpoint = f"http://0.0.0.0:{port}/health"
130
131 if os.path.exists(LOG_FILE):
132 with open(LOG_FILE, "r") as f:
133 msg = f.readlines()
134 result = parse_tqdm_progress(msg)
135
136 try:
137 response = requests.get(health_check_endpoint, timeout=2)
138 return response.status_code == 200, result
139 except requests.exceptions.RequestException as e:
140 print(f"Failed to check server health: {e}")
141 return False, result
142
143
144def parse_tqdm_progress(log_lines):

Callers 4

start_serviceFunction · 0.85
service_statusFunction · 0.85
get_configFunction · 0.85
generateFunction · 0.85

Calls 5

get_server_pidFunction · 0.85
parse_tqdm_progressFunction · 0.85
printFunction · 0.85
existsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected