增加status.json加载失败时的容错处理.
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
# -*- coding:utf-8 -*-
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
import sys
|
import sys
|
||||||
@@ -57,8 +58,12 @@ class QueryLog(BaseLog):
|
|||||||
if not Config.is_cluster_enabled() and path.exists(self.data_path):
|
if not Config.is_cluster_enabled() and path.exists(self.data_path):
|
||||||
with open(self.data_path, encoding='utf-8') as f:
|
with open(self.data_path, encoding='utf-8') as f:
|
||||||
result = f.read()
|
result = f.read()
|
||||||
if result:
|
try:
|
||||||
result = json.loads(result)
|
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():
|
if Config.is_cluster_enabled():
|
||||||
result = self.get_data_from_cluster()
|
result = self.get_data_from_cluster()
|
||||||
|
|||||||
Reference in New Issue
Block a user