consul以服务方式运行,可以达到开机自启动和故障自动重启,减轻运维负担。
如下是脚本,使用方法是:复制该文件到/usr/lib/systemd/system/下,运行systemctl daemon-reload;systemctl start consul.
### BEGIN INIT INFO
## Provides: Varnson
## Short-Description: Consul agent
## Description: Consul service discovery framework
## PATH: /usr/lib/systemd/system/
#### END INIT INFO
[Unit]
Description=Consul server agent
Requires=network-online.target
After=network-online.target
[Service