(path, lines=50)
| 482 | if elapsed >= timeout: |
| 483 | |
| 484 | def tail_file(path, lines=50): |
| 485 | try: |
| 486 | with open(path, "r", encoding="utf-8", errors="ignore") as f: |
| 487 | return "".join(f.readlines()[-lines:]) |
| 488 | except Exception as e: |
| 489 | return f"[无法读取 {path}]: {e}, {str(traceback.format_exc())}\n" |
| 490 | |
| 491 | result = f"服务启动超时,耗时:[{timeout}s]\n\n" |
| 492 | result += "==== server.log tail 50 ====\n" |