confd
https://cloud.tencent.com/developer/article/1444852
测试配置 /etc/confd/conf.d/test_user.toml
[template]
src = "test_user.tmpl"
dest = "/tmp/myapp.conf"
owner = "root"
mode = "0644"
keys = [
"/company/users/test1",
"/company/users/test2",
]
check_cmd = "echo {{.src}} >> /tmp/test_confd.log"
reload_cmd = "echo `date` >> /tmp/test_confd.log && cat /tmp/myapp.conf >> /tmp/test_confd.log"
自动生成配置的模板 /etc/confd/templates/test_user.tmpl
server{1}
{{range gets "/company/users/test1"}}
key: {{.Key}}
value: {{.Value}}
name {{ $data := json .Value }} {{ $data.age }}
{{end}}
# session 1
bash> etcd
# session 2
bash> etcdctl --endpoints=127.0.0.1:2379 put /company/users/test1 '{"age": "1"}'
# session 3
bash> rm -rf /tmp/myapp.conf && confd -onetime -backend etcdv3 -node http://127.0.0.1:2379
使用守护进程方式
confd -watch -backend etcdv3 -node http://127.0.0.1:2379
etcd
https://github.com/etcd-io/etcd/releases
echo "ETCD_HOME=/usr/local/etcd/bin" >> /etc/profile
echo "PATH=$ETCD_HOME:$PATH" >> /etc/profile
source /etc/profile
浙公网安备 33010602011771号