Repository navigation
feat: 保留进程崩溃诊断日志并升级至 2.0.7 - #17
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
2026-10-23 凌晨代理最后一条成功请求记录在 02:35:35,直到 07:38 手动启动前没有进一步进程日志;现有业务日志无法区分进程意外退出、终端结束或强制终止,也无法稳定保留 Python/Uvicorn 控制台错误。
本 PR 从当前远端
main(eca6f70)直接创建,只有进程诊断与 2.0.7 版本升级,不改业务协议、转发、认证、签到或模型处理流程。实现
ProcessDiagnostics用 Tee 同步显示并保存 Python 层 stdout/stderr(包括 traceback / Uvicorn 错误),写入console.log,20 MiB × 当前文件 + 4 个历史文件,落盘并按大小轮转;不中断现有控制台输出。Python fatal fault 经faulthandler保存到crash.log。process-events.jsonl(2 MiB × 当前文件 + 3 个历史文件),记录 PID、run_id、启动、正常返回、非零返回、SystemExit、KeyboardInterrupt、未捕获致命异常、退出码及运行时长。代理的主入口包裹进程诊断管理器,保留原有成功/失败退出码语义。previous_run_exit_unobserved(不是已证实崩溃;并行实例也可能出现该事件)。diagnostic_log_failure,并向原始 stderr 提示;避免诊断功能自身导致代理中断。结构化日志只记录异常类型与关键数值,不写敏感的请求正文。pyproject.toml的包版本与 FastAPI metadata 升级为2.0.7;中英文 README 补充日志入口,新增docs/process-diagnostics-2.0.7.md(查看方法、安全说明、可观测性限制)。验证
test_process_diagnostics.py:22 passed,涵盖正常/异常退出、非零退出码、异常 traceback、SIGTERM、强制杀死子进程并在下次启动观测缺失退出事件、Console Tee 与轮转、日志故障降级、未处理异步/线程异常、主入口接入、2.0.7 版本。stat.S_IMODE(...) == 0o600断言;未修改该测试)。compileall及 Git whitespace 检查通过。mainahead 1 / behind 0,共 7 个文件;本地没有未提交内容。未创建
2.0.7Tag 或 Release,也没有重启正在运行的本地代理。建议代码评审通过后合并,再由维护者完成版本标签和 GitHub Release 流程。