fix(backend): Ensure import runs on startup via scheduler
Some checks failed
Deploy Fediversion / deploy (push) Failing after 1s
Some checks failed
Deploy Fediversion / deploy (push) Failing after 1s
This commit is contained in:
parent
f026cb2423
commit
be5921b6ee
1 changed files with 8 additions and 0 deletions
|
|
@ -17,7 +17,15 @@ def daily_import_job():
|
|||
except Exception as e:
|
||||
logger.error(f"Daily import failed: {e}")
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
def start_scheduler():
|
||||
# Regular interval
|
||||
scheduler.add_job(daily_import_job, 'interval', hours=12, id='goose_import')
|
||||
|
||||
# Run once on startup (with 10s delay to let server settle)
|
||||
run_date = datetime.now() + timedelta(seconds=10)
|
||||
scheduler.add_job(daily_import_job, 'date', run_date=run_date, id='goose_import_startup')
|
||||
|
||||
scheduler.start()
|
||||
logger.info("Scheduler started with daily import job.")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue