編寫服務開機自啓動

啓動腳本bash

vi /usr/local/consul/start.sh

#!/bin/bash
/usr/local/bin/consul agent -config-dir=/etc/consul.d > /data/consul/consul.log

啓動服務ide

vi /usr/lib/systemd/system/consul.service

[Unit]
Description=consul
After=network.target

[Service]
ExecStart=/usr/local/consul/start.sh
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target

添加執行權限
chmod +x /usr/local/consul/start.shcode

啓動
systemctl start consul ip

開機運行
systemctl enable consul get

相關文章
相關標籤/搜索