修改注册系统服务时的配置项

This commit is contained in:
lwch
2022-08-29 10:50:26 +08:00
parent 813fd7dcd2
commit 419b16421b
+19
View File
@@ -63,6 +63,24 @@ func main() {
if rt.GOOS != "windows" {
depends = append(depends, "After=network.target")
}
var opt service.KeyValue
switch rt.GOOS {
case "windows":
opt = service.KeyValue{
"StartType": "automatic",
"OnFailure": "restart",
"OnFailureDelayDuration": "5s",
"OnFailureResetPeriod": 10,
}
case "linux":
opt = service.KeyValue{
"LimitNOFILE": 65000,
}
case "darwin":
opt = service.KeyValue{
"SessionCreate": true,
}
}
appCfg := &service.Config{
Name: "np-cli",
@@ -71,6 +89,7 @@ func main() {
UserName: *user,
Arguments: []string{"-conf", dir},
Dependencies: depends,
Option: opt,
}
cfg := global.LoadConf(*conf)