将 Go 应用注册为 linux 系统服务

将 Go 应用注册为系统服务

vim /etc/systemd/system/my-web.service

[Unit]
Description=My Web Service

[Service]
ExecStart=/data/web/my-web/go-whisper
WorkingDirectory=/data/web/my-web/
Restart=always
RestartSec=10
KillSignal=SIGINT
SyslogIdentifier=something-web-service
User=ubuntu

[Install]
WantedBy=multi-user.target

启用服务:sudo systemctl enable my-web.service 开始服务:sudo systemctl status my-web.service