summaryrefslogtreecommitdiff
path: root/services/news-collector
diff options
context:
space:
mode:
Diffstat (limited to 'services/news-collector')
-rw-r--r--services/news-collector/src/news_collector/main.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/services/news-collector/src/news_collector/main.py b/services/news-collector/src/news_collector/main.py
index f56914f..837a397 100644
--- a/services/news-collector/src/news_collector/main.py
+++ b/services/news-collector/src/news_collector/main.py
@@ -13,6 +13,7 @@ from shared.models import NewsItem
from shared.notifier import TelegramNotifier
from shared.sentiment_models import MarketSentiment
from shared.sentiment import SentimentAggregator
+from shared.shutdown import GracefulShutdown
from news_collector.config import NewsCollectorConfig
from news_collector.collectors.finnhub import FinnhubCollector
@@ -143,6 +144,9 @@ async def run() -> None:
news_collectors = [finnhub, rss, sec, truth, reddit, fed]
+ shutdown = GracefulShutdown()
+ shutdown.install_handlers()
+
log.info(
"starting",
collectors=[c.name for c in news_collectors],
@@ -171,7 +175,7 @@ async def run() -> None:
name="aggregator-loop",
)
)
- await asyncio.gather(*tasks)
+ await shutdown.wait()
except Exception as exc:
log.error("fatal_error", error=str(exc))
await notifier.send_error(str(exc), "news-collector")