上传配置以及pyhont 工具脚本
This commit is contained in:
parent
670342ec91
commit
e394fc8e44
@ -1,4 +1,4 @@
|
||||
id : "worker_2" #服务的唯一id 在集群服务下不能重复即可 建议配置文件名与服务id一致
|
||||
id : "worker_1" #服务的唯一id 在集群服务下不能重复即可 建议配置文件名与服务id一致
|
||||
ip : "127.0.0.1" #运行主机Ip 集群通信中 按ip节点通行的查询字段 此字段可以注释掉 注释后取当前运行主机公网ip地址
|
||||
port : 9568 #服务监听端口 RPC服务
|
||||
tag : "dreamfactory" #服务集群标签 相同标签 且sys.registry 和 sys.rpc 配置一致 即可互相发现和通信
|
||||
@ -9,7 +9,7 @@ version : 1.0 #服务版本 多服务器相同
|
||||
#系统配置
|
||||
sys:
|
||||
log: #日志系统
|
||||
FileName: "./log/worker_2.log" #日志文件存放地址
|
||||
FileName: "./log/worker_1.log" #日志文件存放地址
|
||||
Loglevel: 0 #日志文件输出级别
|
||||
LogMaxSize: 128 #日志文件最大Size
|
||||
LogMaxAge: 7 #日志文件最多保留天数
|
||||
|
35
py_consul.py
Normal file
35
py_consul.py
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# encoding: utf-8
|
||||
import requests
|
||||
import json
|
||||
|
||||
host = '10.0.0.9'
|
||||
port = 8500
|
||||
|
||||
#consul中微服务名称
|
||||
serviceNames='dreamfactory'
|
||||
|
||||
def get_service():
|
||||
url = 'http://'+host+':'+str(port)+'/v1/agent/services'
|
||||
data = requests.get(url).json()
|
||||
jsonStr = json.dumps(data)
|
||||
print('json '+jsonStr)
|
||||
keys = []
|
||||
for k in data:
|
||||
serviceName=data[k]['Service']
|
||||
if serviceName in serviceNames:
|
||||
print(data[k]['Service'])
|
||||
print(data[k]['ID'])
|
||||
keys.append(k)
|
||||
return keys
|
||||
|
||||
def del_service(keys):
|
||||
url = 'http://'+host+':'+str(port)+'/v1/agent/service/deregister/'
|
||||
for sid in keys:
|
||||
requests.put(url+sid)
|
||||
print('删除 '+sid)
|
||||
|
||||
if __name__ == '__main__':
|
||||
keys = get_service()
|
||||
del_service(keys)
|
Loading…
Reference in New Issue
Block a user