|
@@ -28,6 +28,11 @@ from news_mcp.entity_normalize import normalize_query
|
|
|
from news_mcp.related_entities import related_recent_entities
|
|
from news_mcp.related_entities import related_recent_entities
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+logging.basicConfig(
|
|
|
|
|
+ level=logging.INFO,
|
|
|
|
|
+ format="%(asctime)s %(levelname)s %(name)s: %(message)s",
|
|
|
|
|
+)
|
|
|
|
|
+
|
|
|
mcp = FastMCP(
|
|
mcp = FastMCP(
|
|
|
"news-mcp",
|
|
"news-mcp",
|
|
|
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
|
|
transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
|
|
@@ -692,14 +697,17 @@ async def _start_background_refresh():
|
|
|
|
|
|
|
|
async def _loop():
|
|
async def _loop():
|
|
|
if not NEWS_BACKGROUND_REFRESH_ON_START:
|
|
if not NEWS_BACKGROUND_REFRESH_ON_START:
|
|
|
|
|
+ logger.info("background refresh delayed start interval_seconds=%s", NEWS_REFRESH_INTERVAL_SECONDS)
|
|
|
await asyncio.sleep(float(NEWS_REFRESH_INTERVAL_SECONDS))
|
|
await asyncio.sleep(float(NEWS_REFRESH_INTERVAL_SECONDS))
|
|
|
while True:
|
|
while True:
|
|
|
try:
|
|
try:
|
|
|
|
|
+ logger.info("background refresh tick start")
|
|
|
# Refresh all topics by passing topic=None
|
|
# Refresh all topics by passing topic=None
|
|
|
await refresh_clusters(topic=None, limit=200)
|
|
await refresh_clusters(topic=None, limit=200)
|
|
|
|
|
+ logger.info("background refresh tick complete")
|
|
|
except Exception:
|
|
except Exception:
|
|
|
- # Avoid crashing the server on network errors.
|
|
|
|
|
- pass
|
|
|
|
|
|
|
+ # Keep the server alive, but do not hide the failure.
|
|
|
|
|
+ logger.exception("background refresh tick failed")
|
|
|
await asyncio.sleep(float(NEWS_REFRESH_INTERVAL_SECONDS))
|
|
await asyncio.sleep(float(NEWS_REFRESH_INTERVAL_SECONDS))
|
|
|
|
|
|
|
|
asyncio.create_task(_loop())
|
|
asyncio.create_task(_loop())
|