我正在使用consul在我的环境中发现服务。Consul 的 DNS 服务运行在非标准的 DNS 端口上。我目前的解决方案更多的是解决方法,我想找到更pythonic的方法来做到这一点:
digcmd='dig @127.0.0.1 -p 8600 chef.service.consul +short' # lookup the local chef server via consul
proc=subprocess.Popen(shlex.split(digcmd),stdout=subprocess.PIPE)
out, err=proc.communicate()
chef_server = "https://"+out.strip('\n')