diff --git a/control/rebalance.py b/control/rebalance.py index 65cae497a..3bdc3eba4 100755 --- a/control/rebalance.py +++ b/control/rebalance.py @@ -13,6 +13,8 @@ import time import json import re +import os +import signal from .utils import GatewayLogger from .config import GatewayConfig from .proto import gateway_pb2 as pb2 @@ -40,8 +42,10 @@ def auto_rebalance_task(self ): self.logger.debug(f"Nothing found for rebalance, break at {i} iteration") break except Exception: - self.logger.exception(f"Exception in auto rebalance") - raise + self.logger.exception(f"Exception in auto rebalance") + parent_pid = os.getppid() + os.kill(parent_pid, signal.SIGTERM) + raise SystemExit(f"auto rebalance failed, quitting gateway") time.sleep(0.01) #release lock for 10ms after rebalancing each 1 NS time.sleep(self.rebalance_period_sec)