agentd: fix graceful shutdown (SIGTERM handling)

t-564·WorkTask·
·
·
·Omni/Agent.hs
Created1 week ago·Updatedyesterday

Description

Edit

agentd does not shut down gracefully on SIGTERM. systemd sends SIGTERM, waits the timeout, then sends SIGKILL. The service should: (1) catch SIGTERM, (2) send SIGTERM to all child pi processes, (3) wait briefly for them to exit, (4) close log handles and clean up, (5) exit 0. Currently it hangs, likely because the log reader threads or child process watchers aren't being interrupted.

Timeline (4)

🔄[human]Open → InProgressyesterday
🔄[human]InProgress → Reviewyesterday
💬[human]yesterday

Fixed in b697c45: Signal handler uses MVar to prevent double-shutdown. Calls exitSuccess after gracefulShutdown. Wraps per-agent stop in try/catch. Closes SQLite on shutdown.