增加status.json加载失败时的容错处理.

This commit is contained in:
a2r0n
2019-01-17 14:41:59 +08:00
parent 3e7616ccea
commit eb8d1f5a97

View File

@@ -1,3 +1,4 @@
# -*- coding:utf-8 -*-
import datetime
import json
import sys
@@ -57,8 +58,12 @@ class QueryLog(BaseLog):
if not Config.is_cluster_enabled() and path.exists(self.data_path):
with open(self.data_path, encoding='utf-8') as f:
result = f.read()
if result:
try:
result = json.loads(result)
except json.JSONDecodeError as e:
self.add_quick_log('加载status.json失败, 文件内容为: {}.'.format(repr(result)))
self.flush()
result = {}
if Config.is_cluster_enabled():
result = self.get_data_from_cluster()