summaryrefslogtreecommitdiff
path: root/src/srht_contrib/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/srht_contrib/main.py')
-rw-r--r--src/srht_contrib/main.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/srht_contrib/main.py b/src/srht_contrib/main.py
index 9047bcc..c6038cb 100644
--- a/src/srht_contrib/main.py
+++ b/src/srht_contrib/main.py
@@ -2,6 +2,7 @@ from __future__ import annotations
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
+import logging
from apscheduler.schedulers.background import BackgroundScheduler
from fastapi import FastAPI
@@ -21,6 +22,9 @@ from srht_contrib.services.todo import TodoIngestionService
from srht_contrib.utils.identity import ActorIdentityResolver
+logger = logging.getLogger(__name__)
+
+
def build_poller(settings: Settings) -> PollerService:
todo_client = SourceHutGraphQLClient(settings.todo_srht_endpoint, settings.srht_token)
git_client = SourceHutGraphQLClient(settings.git_srht_endpoint, settings.srht_token)
@@ -68,6 +72,7 @@ def create_app(
replace_existing=True,
)
scheduler.start()
+ _run_startup_poll(app)
app.state.scheduler = scheduler
try:
yield
@@ -96,4 +101,11 @@ def _scheduled_poll(app: FastAPI) -> None:
db.close()
+def _run_startup_poll(app: FastAPI) -> None:
+ try:
+ _scheduled_poll(app)
+ except Exception:
+ logger.exception("Initial scheduled poll failed during application startup")
+
+
app = create_app()