# -*- coding: utf-8 -*- """票 04:强制结束旧 crm-app 进程并确认 8080 释放。""" import io, sys, subprocess, time sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') r = subprocess.run(['taskkill', '/F', '/T', '/PID', '37420'], capture_output=True, text=True, shell=False) print('rc=', r.returncode) print('out=', r.stdout) print('err=', r.stderr) time.sleep(3) r2 = subprocess.run(['netstat', '-ano'], capture_output=True, text=True, shell=False) listeners = [l for l in r2.stdout.splitlines() if ':8080' in l and 'LISTENING' in l] print('8080 listeners after kill:', listeners if listeners else 'NONE - port free')