配置consul-template启动
[root@consul consul]# consul-template -consul-addr 20.0.0.50:8500 \
-template "/root/consul/nginx.ctmpl:/usr/local/nginx/conf/vhost/chu.conf:/usr/local/nginx/sbin/nginx -s reload" \
--log-level=info
2020/12/01 16:23:39.716020 [INFO] consul-template v0.19.3 (ebf2d3d)
2020/12/01 16:23:39.716032 [INFO] (runner) creating new runner (dry: false, once: false)
2020/12/01 16:23:39.716271 [INFO] (runner) creating watcher
2020/12/01 16:23:39.716340 [INFO] (runner) starting
2020/12/01 16:23:39.716350 [INFO] (runner) initiating run
2020/12/01 16:23:39.717923 [INFO] (runner) initiating run
2020/12/01 16:23:39.719316 [INFO] (runner) rendered "/root/consul/nginx.ctmpl" => "/usr/local/nginx/conf/vhost/chu.conf"
2020/12/01 16:23:39.719335 [INFO] (runner) executing command "/usr/local/nginx/sbin/nginx -s reload" from "/root/consul/nginx.ctmpl" => "/usr/local/nginx/conf/vhost/chu.conf"
2020/12/01 16:23:39.719368 [INFO] (child) spawning: /usr/local/nginx/sbin/nginx -s reload
nginx: [emerg] duplicate upstream "http_backend" in /usr/local/nginx/conf/vhost/kgc.conf:1
2020/12/01 16:23:39.721047 [ERR] (cli) 1 error occurred:
* failed to execute command "/usr/local/nginx/sbin/nginx -s reload" from "/root/consul/nginx.ctmpl" => "/usr/local/nginx/conf/vhost/chu.conf": child: command exited with a non-zero exit status:
/usr/local/nginx/sbin/nginx -s reload
This is assumed to be a failure. Please ensure the command
exits with a zero exit status.
#重新配置consul-template启动
[root@consul consul]# consul-template -consul-addr 20.0.0.50:8500 -template "/root/consul/nginx.ctmpl:/usr/local/nginx/conf/vhost/hyc.conf:/usr/local/nginx/sbin/nginx -s reload" --log-level=info
2020/12/01 16:24:54.980147 [INFO] consul-template v0.19.3 (ebf2d3d)
2020/12/01 16:24:54.980158 [INFO] (runner) creating new runner (dry: false, once: false)
2020/12/01 16:24:54.980372 [INFO] (runner) creating watcher
2020/12/01 16:24:54.980434 [INFO] (runner) starting
2020/12/01 16:24:54.980444 [INFO] (runner) initiating run
2020/12/01 16:24:54.982193 [INFO] (runner) initiating run