feat: live последние события на Dashboard; retention, health, runbook
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
"""CLI: python -m app.jobs.retention"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
|
||||
from app.config import get_settings
|
||||
from app.database import SessionLocal
|
||||
from app.services.retention import purge_old_data
|
||||
|
||||
logging.basicConfig(level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s")
|
||||
logger = logging.getLogger("sac.retention")
|
||||
|
||||
|
||||
def main() -> int:
|
||||
settings = get_settings()
|
||||
db = SessionLocal()
|
||||
try:
|
||||
stats = purge_old_data(db, settings)
|
||||
logger.info(
|
||||
"retention done events_deleted=%s problems_deleted=%s",
|
||||
stats["events_deleted"],
|
||||
stats["problems_deleted"],
|
||||
)
|
||||
return 0
|
||||
except Exception:
|
||||
db.rollback()
|
||||
logger.exception("retention failed")
|
||||
return 1
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user