From 0e177eafbed026445e50da6a5992177521fb8212 Mon Sep 17 00:00:00 2001 From: TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:42:12 +0900 Subject: feat: add graceful shutdown with SIGTERM/SIGINT handlers to all services --- services/order-executor/src/order_executor/main.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'services/order-executor') diff --git a/services/order-executor/src/order_executor/main.py b/services/order-executor/src/order_executor/main.py index 1d167ef..63d93bc 100644 --- a/services/order-executor/src/order_executor/main.py +++ b/services/order-executor/src/order_executor/main.py @@ -11,6 +11,7 @@ from shared.healthcheck import HealthCheckServer from shared.logging import setup_logging from shared.metrics import ServiceMetrics from shared.notifier import TelegramNotifier +from shared.shutdown import GracefulShutdown from order_executor.config import ExecutorConfig from order_executor.executor import OrderExecutor @@ -83,6 +84,9 @@ async def run() -> None: await broker.ensure_group(stream, GROUP) + shutdown = GracefulShutdown() + shutdown.install_handlers() + log.info("started", stream=stream, dry_run=config.dry_run) try: @@ -97,7 +101,7 @@ async def run() -> None: except Exception as exc: log.error("pending_failed", error=str(exc), msg_id=msg_id) - while True: + while not shutdown.is_shutting_down: messages = await broker.read_group(stream, GROUP, CONSUMER, count=10, block=5000) for msg_id, msg in messages: try: -- cgit v1.2.3