def register(): """注册进入consul中""" # 读取配置文件 conf = config.CONF # 生成健康检查配置 check = Check().tcp(host=conf["consul"]["service"]["address"], port=conf["consul"]["service"]["port"], interval=conf["consul"]["service"]["interval"], timeout=conf["consul"]["service"]["timeout"], deregister=conf["consul"]["service"]["deregister"]) # 设置健康检查 _consul.agent.service.register( name=conf["consul"]["service"]["name"], service_id=conf["consul"]["service"]["service_id"], address=conf["consul"]["service"]["address"], port=conf["consul"]["service"]["port"], check=check) logging.info("服务注册进入consul")