mirror of
https://github.com/thingsboard/thingsboard-gateway
synced 2025-10-26 22:31:42 +08:00
Fixed gateway stopping
This commit is contained in:
@@ -60,7 +60,7 @@ try:
|
||||
except ImportError:
|
||||
print("Cannot load GRPC connector!")
|
||||
|
||||
log = TbLogger('service')
|
||||
log = None
|
||||
main_handler = logging.handlers.MemoryHandler(-1)
|
||||
|
||||
DEFAULT_CONNECTORS = {
|
||||
@@ -140,7 +140,7 @@ class GatewayManager(multiprocessing.managers.BaseManager):
|
||||
self.gateway = gateway
|
||||
|
||||
def shutdown(self) -> None:
|
||||
pass
|
||||
super().shutdown()
|
||||
|
||||
|
||||
class TBGatewayService:
|
||||
@@ -509,7 +509,7 @@ class TBGatewayService:
|
||||
self.__updater.stop()
|
||||
log.info("Stopping...")
|
||||
|
||||
if self.__statistics_service:
|
||||
if hasattr(self, '_TBGatewayService__statistics_service'):
|
||||
self.__statistics_service.stop()
|
||||
|
||||
if self.__grpc_manager is not None:
|
||||
|
||||
@@ -42,7 +42,7 @@ class TBLoggerHandler(logging.Handler):
|
||||
'storage'
|
||||
]
|
||||
for logger in self.loggers:
|
||||
log = TbLogger(logger)
|
||||
log = TbLogger(name=logger, gateway=gateway)
|
||||
log.addHandler(self.__gateway.main_handler)
|
||||
log.debug("Added remote handler to log %s", logger)
|
||||
|
||||
@@ -56,10 +56,10 @@ class TBLoggerHandler(logging.Handler):
|
||||
for logger in self.loggers:
|
||||
if log_level is not None and logging.getLevelName(log_level) is not None:
|
||||
if logger == 'tb_connection' and log_level == 'DEBUG':
|
||||
log = TbLogger(logger)
|
||||
log = TbLogger(logger, gateway=self.__gateway)
|
||||
log.setLevel(logging.getLevelName('INFO'))
|
||||
else:
|
||||
log = TbLogger(logger)
|
||||
log = TbLogger(logger, gateway=self.__gateway)
|
||||
self.current_log_level = log_level
|
||||
log.setLevel(logging.getLevelName(log_level))
|
||||
except Exception as e:
|
||||
|
||||
@@ -72,13 +72,13 @@ class TbLogger(logging.Logger):
|
||||
|
||||
def _send_errors(self):
|
||||
is_tb_client = False
|
||||
while not is_tb_client:
|
||||
while not is_tb_client and not self._gateway.stopped:
|
||||
is_tb_client = hasattr(self._gateway, 'tb_client')
|
||||
sleep(1)
|
||||
|
||||
if not TbLogger.IS_ALL_ERRORS_COUNT_RESET:
|
||||
if not TbLogger.IS_ALL_ERRORS_COUNT_RESET and self._gateway.tb_client.is_connected():
|
||||
self._gateway.tb_client.client.send_telemetry(
|
||||
{self.attr_name: 0, 'ALL_ERRORS_COUNT': 0})
|
||||
{self.attr_name: 0, 'ALL_ERRORS_COUNT': 0}, quality_of_service=0)
|
||||
TbLogger.IS_ALL_ERRORS_COUNT_RESET = True
|
||||
self._is_on_init_state = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user