Linux 安装pyappollo并访问Apollo获取配置
appollo安装与部署
下载地址:链接:https://pan.baidu.com/s/1FdRS2wSHk72pPi6_FuhA4g
提取码:nr3p
pip安装命令:
python3 setup.py install
安装如下图
使用示例1
def apollo_fun():
try:
client = ApolloClient(app_id="guomeispider-py", config_server_url=apollo_url,timeout=5)
guomei_sellerId1=client.get_value("TAOBAO_SELLERID_LIST")
guomei_sellerId2 = client.get_value("SHIELD_PARAMS_LIST")
GUOMEI_SELLERID_LIST=set(taobao_sellerId_str.split(","))
SHIELD_PARAMS_LIST = set(taobao_sellerId_str2.split(","))
# pass
except:
from common.setting import SHIELD_PARAMS_LIST,TAOBAO_SELLERID_LIST
# print(TAOBAO_SELLERID_LIST)
return (TAOBAO_SELLERID_LIST,SHIELD_PARAMS_LIST)
if __name__ == '__main__':
res=apollo_fun()[1]
print(res)
使用示例2
import pyapollo
a = pyapollo.ApolloClient("test1","default","http://192.168.1.100:8080")
a.start()
for key in ["ip","port"]:
v = a.get_value(key)
print("%s : " % key)
print(v)