# -*- coding: utf-8 -*- """票 04:等待服务启动完成(轮询 t04-run.log + 8080 健康探测)。""" import io, sys, time sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') log = r'e:\code\crm-backend-matt\logs\t04-run.log' deadline = time.time() + 120 started = False while time.time() < deadline: try: txt = open(log, encoding='utf-8', errors='replace').read() except FileNotFoundError: txt = '' if 'Started CrmApplication' in txt: started = True break if 'APPLICATION FAILED TO START' in txt or 'BUILD FAILURE' in txt: print('SERVICE FAILED') idx = txt.find('APPLICATION FAILED TO START') print(txt[idx:idx + 1500] if idx >= 0 else txt[-1500:]) sys.exit(2) time.sleep(5) print('STARTED' if started else 'TIMEOUT') try: import requests r = requests.get('http://localhost:8080/api/auth/debug/token', params={'userId': '739564171091247104'}, timeout=10) print('health:', r.status_code, r.text[:120]) except Exception as e: print('health probe failed:', e)