Closed general

Instances never die: add a 24h idle self-shutdown with a lossless final snapshot

John Lauer · 2mo ago ·closed by Colby Knox

Field report, 2026-08-11: one container had accumulated 13 live hero-studio instances over 3 days (ports 8846-8858 and 8862, roughly 600MB RSS). Twelve of them predated the current release; two were running from deleted install directories after a package update, so their snapshot writes were silently failing. Only the newest instance even had the polite POST /shutdown from #26, and no driving agent ever called it.

The lesson from #26 is structural: agents forget, so relying on the caller to stop the server is not a lifecycle plan. Proposal:

  1. Track lastActivity on every HTTP request. When the server has been idle for 24h (configurable via --ttl, opt out with --keep-alive), it reaps itself: finish pending work, write a final state snapshot, exit 0.
  2. Resurrection makes the reaper safe: on the next start, restore the snapshot so a reaped studio costs exactly one relaunch, with the pose intact. The existing #32.9 snapshot machinery is most of this already.
  3. Do NOT key the timer to Generate. Idle-reset subsumes it: a hero someone is slowly finishing over days keeps getting touched (clock resets), an approved-and-abandoned studio dies a day later on its own.

Companion issue: thread-keyed identity and per-thread snapshots (filed separately). The general pattern both issues implement is now specified in the app-creator-server-lifecycle sub-skill on the App Creator page.

1 Reply

Colby Knox · 2mo ago

Shipped in 0.17.0, per the app-creator-server-lifecycle contract your issue points at.

  • lastActivity updates on every HTTP request; a once-a-minute timer reaps after 24h idle (--ttl tunes it, --keep-alive opts out, APP_TTL_HOURS env honored). Not keyed to Generate, exactly as you argued: idle-reset subsumes it.
  • The reap is lossless: final state snapshot (checklist, staged imports, ledger), webview tab removal, registry deregistration, exit 0. Verified live with a short TTL: port closed, registry entry pruned, snapshot present, and a same-thread restart restored the pose.
  • Resurrection is the #39 per-thread snapshot machinery, so a reaped studio costs exactly one relaunch with the pose intact.

Your 13-instance field report also motivated the drift detection in ls (#39 close has the details): the two instances running from deleted install dirs are the class hero-studio ls now flags as version drift.

Log in to reply.