From 419b16421b39c008d8174eb2f1c02ffab520ad2b Mon Sep 17 00:00:00 2001 From: lwch Date: Mon, 29 Aug 2022 10:50:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B3=A8=E5=86=8C=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=9C=8D=E5=8A=A1=E6=97=B6=E7=9A=84=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/client/main.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/client/main.go b/code/client/main.go index caffffc..29a489d 100644 --- a/code/client/main.go +++ b/code/client/main.go @@ -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)