参考以下的模板, 现在只有自动启动, 没有重启和关闭的逻辑.
流程
创建一个单元服务文件
[Unit]
Description=填写你service的描述
Documentation=文档网址, 不填
After=network.target
[Service]
ExecStart=/root/test_go_systemd
KillMode=process
Restart=on-failure
User=root
[Install]
WantedBy=multi-user.target
将 service文件移动到指定位置
sudo cp test_go.service /etc/systemd/system/
使用enable启动自启
systemctl enable test_go.service
确认效果
使用 start 和status来验证效果