fix: tini entrypoint, event routing wildcard, orphan recovery
This commit is contained in:
11
src/main.py
11
src/main.py
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user