Update consul_manager.py

pull/122/head
StarsL.cn 2024-03-07 00:04:56 +08:00 committed by GitHub
parent 05be7144d7
commit 88425e7f9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 0 deletions

View File

@ -7,6 +7,9 @@ headers = {'X-Consul-Token': consul_token}
def get_consul_ver():
url = f'{consul_url}/operator/autopilot/state'
response = requests.get(url, headers=headers, timeout=2)
if response.status_code == 404:
url = f'{consul_url}/operator/autopilot/health'
response = requests.get(url, headers=headers, timeout=2)
response.encoding='utf-8'
if response.status_code == 200:
logger.info(f'【consul】请求成功, 认证成功: {consul_url} ')
@ -14,6 +17,9 @@ def get_consul_ver():
elif response.status_code == 403:
logger.error(f'【consul】连接正常: {consul_url}【认证失败】请检查consul token!')
return False
elif response.status_code == 404:
logger.error(f'【consul】连接异常 {response.status_code}: {consul_url}, 您的consul版本可能过低!')
return False
else:
logger.error(f'【consul】连接失败 {response.status_code}: {consul_url}, 请检查consul状态以及网络是否正常!')
return False