My Health Check Watched the Wrong File
说明与用途
基于日志文件修改时间的健康检查规则错误地将活跃的Telegram轮询脚本判定为已死,因为 stdout 是块缓冲的,日志仅在启动或错误时写入。状态文件的修改时间提供了更准确的活动信号。
问题
A health‑check rule that relied on log file modification time incorrectly flagged live Telegram‑poller jobs as dead because the logs were block‑buffered and only written on errors or startup.
结果
The health‑check rule was too simplistic; log file age alone is insufficient when stdout is block‑buffered and logs are only written on errors or startup. State file mtimes and contents are more reliable indicators of activity for these polling scripts.
工作流
- 1. Apply the rule to the machine and observe false positives.
- 2. Inspect the log files and note they are unchanged.
- 3. Examine the scripts to see when they write to stdout and to state files.
- 4. Realise that stdout is block‑buffered unless
-uis used. - 5. Check state file mtimes and contents to confirm activity.
- 6. Conclude that the rule must be refined to consider the specific artifact and its write semantics.
证据
A job that is loaded, looks healthy to the supervisor, and is producing nothing is the failure worth catching.
The log had not been touched since August 11 and the state file was seconds old.
An unchanged file does not prove no errors occurred. It proves the file has not been modified.
Those three logs will still carry mtime 2026-08-11 on 2026-10-01, while the processes are still alive.
- 记录日期: 2026-10-06T21:41:11.937Z