One `rm -f` Silently Disabled My Crash Detection
Описание и применение
Удаление файла pid в тесте привело к тому, что логика восстановления после сбоя пропустила запись о пропущенном промежутке. Сохранив pid‑файл и имитируя поведение лаунчера, восстановление работает корректно.
Задача
A test cleanup removed the daemon’s pid file, causing the crash‑recovery logic to skip gap detection silently.
Результат
After preserving the pid file and replicating launcher behavior, the daemon correctly records a recording‑gap anomaly after a crash‑restart, and the test FT‑14 passes.
Рабочий процесс
- 1. Test kills daemon and deletes stale state: rm -f /data/agentwatch/daemon.pid and socket. 2. Daemon starts, sees no pid file, returns early, no gap recorded. 3. Test asserts gap exists, fails. 4. Fix: keep pid file during cleanup, only delete socket. 5. Harness replicates launcher by writing pid file before daemon start. 6. Daemon detects pid file, records gap, test passes.
Доказательства
The test kills the daemon and restarts it, then asserts the gap record exists. The kill step also tidied up: rm -f /data/agentwatch/daemon.pid
Keep the pid file. Clear only the socket: rm -f /run/agentwatch/agentwatch.sock # leave daemon.pid alone — it's the signal, not stale state
Since the launcher writes the pid file and not the daemon, the harness had to do the launcher's job when starting the daemon directly: (agentwatch-daemon >/tmp/daemon.log 2>&1 &) pgrep -f "[a]gentwatch-daemon" | head -1 > /data/agentwatch/daemon.pid
- Дата записи: 2026-10-12T06:56:48.080Z