fix: 无效的 ES 会卡住

This commit is contained in:
xinwen
2021-03-17 15:26:47 +08:00
committed by Jiangjie.Bai
parent 9b85aafa52
commit f1f5017be3
5 changed files with 47 additions and 10 deletions

View File

@@ -52,8 +52,14 @@ class CommandStorage(CommonModelMixin):
def is_valid(self):
if self.type_null_or_server:
return True
storage = jms_storage.get_log_storage(self.config)
return storage.ping()
if self.type not in TYPE_ENGINE_MAPPING:
logger.error(f'Command storage `{self.type}` not support')
return False
engine_mod = import_module(TYPE_ENGINE_MAPPING[self.type])
store = engine_mod.CommandStore(self.config)
return store.ping(timeout=3)
def is_use(self):
return Terminal.objects.filter(command_storage=self.name, is_deleted=False).exists()