给Consul创建Systemd服务

2019-04-17  本文已影响0人  张大胆_6a19

参考:https://www.hi-linux.com/posts/28048.html

一、路径/usr/lib/systemd/system/,新建一个service命名为,consul.service

[Unit]
Description=consul
After=network.target
    
[Service]
ExecStart=/usr/local/consul/start.sh
KillSignal=SIGTERM
    
[Install]
WantedBy=multi-user.target

二、编辑/usr/local/consul/start.sh,注意LF格式

#!/bin/bash
/usr/bin/consul agent -server -node=192.168.211.202 -data-dir=/usr/local/consul/data/ -config-dir=/usr/local/consul/config/ -log-file=/usr/local/consul/log/consul_log-$(date +%Y-%m-%d--%H-%M) -bind=192.168.211.202 -join=192.168.211.202

三、执行命令

运行

# systemctl start consul 

开机运行

# systemctl enable consul 

四、如果重新加载配置文件,则直接运行consul reload即可,consul leave同理

上一篇 下一篇

猜你喜欢

热点阅读