cleanup old browser instances job
Build and Push Docker Images / build-and-push (push) Successful in 1m0s

This commit is contained in:
2025-08-08 13:43:07 +02:00
parent e8d6807725
commit e819d0ddcb
2 changed files with 141 additions and 0 deletions
+10
View File
@@ -4,6 +4,7 @@ from apscheduler.triggers.cron import CronTrigger
from app.database import init_db, cleanup_old_cache_entries
from app.config import CLEANUP_CRON, CACHE_EXPIRY_HOURS
from app.routes import health, browser, cache
from app.services.browser import force_cleanup_old_pages
# Create FastAPI app
app = FastAPI()
@@ -22,6 +23,14 @@ scheduler.add_job(
replace_existing=True
)
# Add browser cleanup job
scheduler.add_job(
force_cleanup_old_pages,
CronTrigger.from_crontab(CLEANUP_CRON),
id='browser_cleanup_job',
replace_existing=True
)
# Initialize database on startup
init_db()
@@ -31,6 +40,7 @@ def start_scheduler():
scheduler.start()
print(f"Cache cleanup scheduler started with cron: {CLEANUP_CRON}")
print(f"Cache entries will expire after {CACHE_EXPIRY_HOURS} hours")
print("Browser cleanup scheduler started")
# Shutdown the scheduler when the application stops
@app.on_event("shutdown")