增加 cdn 检测超时配置
This commit is contained in:
@@ -104,6 +104,7 @@ WEB_PORT = 8008 # 监听端口
|
|||||||
|
|
||||||
# 是否开启 CDN 查询
|
# 是否开启 CDN 查询
|
||||||
CDN_ENABLED = 0
|
CDN_ENABLED = 0
|
||||||
|
CDN_CHECK_TIME_OUT = 1 # 检测单个 cdn 是否可用超时时间
|
||||||
|
|
||||||
# 查询任务
|
# 查询任务
|
||||||
QUERY_JOBS = [
|
QUERY_JOBS = [
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ WEB_PORT = 8008 # 监听端口
|
|||||||
|
|
||||||
# 是否开启 CDN 查询
|
# 是否开启 CDN 查询
|
||||||
CDN_ENABLED = 0
|
CDN_ENABLED = 0
|
||||||
|
CDN_CHECK_TIME_OUT = 1 # 检测单个 cdn 是否可用超时时间
|
||||||
|
|
||||||
# 查询任务
|
# 查询任务
|
||||||
QUERY_JOBS = [
|
QUERY_JOBS = [
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ class Config:
|
|||||||
|
|
||||||
# CDN
|
# CDN
|
||||||
CDN_ENABLED = 0
|
CDN_ENABLED = 0
|
||||||
|
CDN_CHECK_TIME_OUT = 2
|
||||||
CDN_ITEM_FILE = PROJECT_DIR + 'data/cdn.txt'
|
CDN_ITEM_FILE = PROJECT_DIR + 'data/cdn.txt'
|
||||||
CDN_ENABLED_AVAILABLE_ITEM_FILE = QUERY_DATA_DIR + 'available.json'
|
CDN_ENABLED_AVAILABLE_ITEM_FILE = QUERY_DATA_DIR + 'available.json'
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Cdn:
|
|||||||
|
|
||||||
safe_stay_time = 0.2
|
safe_stay_time = 0.2
|
||||||
retry_num = 1
|
retry_num = 1
|
||||||
thread_num = 8
|
thread_num = 5
|
||||||
check_time_out = 3
|
check_time_out = 3
|
||||||
|
|
||||||
last_check_at = 0
|
last_check_at = 0
|
||||||
@@ -40,6 +40,7 @@ class Cdn:
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.cluster = Cluster()
|
self.cluster = Cluster()
|
||||||
|
self.init_config()
|
||||||
create_thread_and_run(self, 'watch_cdn', False)
|
create_thread_and_run(self, 'watch_cdn', False)
|
||||||
|
|
||||||
def init_data(self):
|
def init_data(self):
|
||||||
@@ -50,8 +51,12 @@ class Cdn:
|
|||||||
self.is_ready = False
|
self.is_ready = False
|
||||||
self.is_recheck = False
|
self.is_recheck = False
|
||||||
|
|
||||||
|
def init_config(self):
|
||||||
|
self.check_time_out = Config().CDN_CHECK_TIME_OUT
|
||||||
|
|
||||||
def update_cdn_status(self, auto=False):
|
def update_cdn_status(self, auto=False):
|
||||||
if auto:
|
if auto:
|
||||||
|
self.init_config()
|
||||||
if Config().is_cdn_enabled():
|
if Config().is_cdn_enabled():
|
||||||
self.run()
|
self.run()
|
||||||
else:
|
else:
|
||||||
@@ -100,7 +105,7 @@ class Cdn:
|
|||||||
if self.last_check_at: self.last_check_at = str_to_time(self.last_check_at)
|
if self.last_check_at: self.last_check_at = str_to_time(self.last_check_at)
|
||||||
self.available_items = result.get('items', [])
|
self.available_items = result.get('items', [])
|
||||||
self.unavailable_items = result.get('fail_items', [])
|
self.unavailable_items = result.get('fail_items', [])
|
||||||
CommonLog.add_quick_log(CommonLog.MESSAGE_CDN_RESTORE_SUCCESS.format(self.last_check_at )).flush()
|
CommonLog.add_quick_log(CommonLog.MESSAGE_CDN_RESTORE_SUCCESS.format(self.last_check_at)).flush()
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user