You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
2.0 KiB

# -*- coding: utf-8 -*-
"""诊断 restart_service 健康检查:无鉴权端点 vs pool/page(带 token)各自返回什么。"""
import io, sys, time
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import requests
BASE = 'http://localhost:8080'
print('--- 1) 无鉴权端点 debug/token ---')
t0 = time.time()
try:
r = requests.get(f'{BASE}/api/auth/debug/token', params={'userId': '739564171091247104'}, timeout=10)
print(f'HTTP {r.status_code} {time.time()-t0:.1f}s body={r.text[:80]}')
except Exception as e:
print(f'{time.time()-t0:.1f}s EXC {type(e).__name__}: {str(e)[:80]}')
print('--- 2) pool/page 无 token ---')
t0 = time.time()
try:
r = requests.get(f'{BASE}/api/customer/pool/page', params={'pageSize': 1}, timeout=10)
print(f'HTTP {r.status_code} {time.time()-t0:.1f}s body={r.text[:80]}')
except Exception as e:
print(f'{time.time()-t0:.1f}s EXC {type(e).__name__}: {str(e)[:80]}')
print('--- 3) pool/page 带 admin token ---')
try:
tk = requests.get(f'{BASE}/api/auth/debug/token',
params={'userId': '739564171091247104'}, timeout=10).json().get('data')
tok = tk if isinstance(tk, str) else (tk or {}).get('token')
t0 = time.time()
r = requests.get(f'{BASE}/api/customer/pool/page', params={'pageSize': 1},
timeout=10, headers={'Authorization': f'Bearer {tok}'})
print(f'HTTP {r.status_code} {time.time()-t0:.1f}s body={r.text[:80]}')
except Exception as e:
print(f'EXC {type(e).__name__}: {str(e)[:120]}')
print('--- 4) 8080 监听进程 ---')
import subprocess
out = subprocess.run('netstat -ano | findstr :8080 | findstr LISTENING',
shell=True, capture_output=True, text=True).stdout
print(out.strip() or '(无监听)')
for line in out.strip().splitlines()[:1]:
pid = line.split()[-1]
cl = subprocess.run(f'wmic process where processid={pid} get commandline /format:list',
shell=True, capture_output=True, text=True).stdout
print('PID', pid, '', cl.replace('\n', ' ')[:160])