cleanup old browser instances job
Build and Push Docker Images / build-and-push (push) Successful in 1m0s
Build and Push Docker Images / build-and-push (push) Successful in 1m0s
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user