diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 15:42:12 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2026-04-02 15:42:12 +0900 |
| commit | 0e177eafbed026445e50da6a5992177521fb8212 (patch) | |
| tree | 84b648112917e05a80fe8e9743c6a66d2259764a /services/news-collector | |
| parent | 913de6b1934881c0a8ee978cf6a0cfd664e1df9a (diff) | |
feat: add graceful shutdown with SIGTERM/SIGINT handlers to all services
Diffstat (limited to 'services/news-collector')
| -rw-r--r-- | services/news-collector/src/news_collector/main.py | 6 |
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") |
