fix: tini entrypoint, event routing wildcard, orphan recovery

This commit is contained in:
Dev Agent
2026-05-22 13:52:46 +03:00
parent c326ef0ac4
commit 0ad56e1f0a
5 changed files with 29 additions and 1 deletions

View File

@@ -15,6 +15,17 @@ logging.basicConfig(
@asynccontextmanager
async def lifespan(app: FastAPI):
init_db()
# Recover orphaned runs
from .db import get_db
conn = get_db()
orphans = conn.execute(
"UPDATE agent_runs SET finished_at=datetime('now'), exit_code=-1 "
"WHERE finished_at IS NULL AND started_at < datetime('now', '-35 minutes')"
).rowcount
conn.commit()
conn.close()
if orphans:
logging.getLogger('orchestrator').warning(f'Recovered {orphans} orphaned agent runs')
yield