我正在尝试在 ubuntu 上使用 gin 框架创建一个 Golang 服务器。在使用 go build 构建后在终端中执行时它工作正常并且在本地同样工作良好。系统化Description=goapp[Service]Type=simpleRestart=alwaysRestartSec=5sExecStart=/home/.../goapp/main[Install]WantedBy=multi-user.target我收到这个错误goapp.service - rediateLoaded: loaded (/lib/systemd/system/goapp.service; disabled; vendor preset: enabled)Active: activating (auto-restart) (Result: exit-code) since Thu 2022-09-29 08:14:10 UTC; 66ms agoProcess: 21628 ExecStart=/home/.../go/goapp/main (code=exited, status=2)Main PID: 21628 (code=exited, status=2)CPU: 9ms
2 回答

大话西游666
TA贡献1817条经验 获得超14个赞
向 systemd 添加工作目录可修复此错误。
Description=goapp
[Service]
Type=simple
Restart=always
RestartSec=
WorkingDirectory=/home/.../goapp
ExecStart=/home/.../goapp/main
[Install]
WantedBy=multi-user.target
- 2 回答
- 0 关注
- 144 浏览
添加回答
举报
0/150
提交
取消