From 41cffb5c65a71aebe458cffa1661e0c1e359456d Mon Sep 17 00:00:00 2001 From: lwch Date: Tue, 6 Sep 2022 14:48:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=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=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- agent.go | 3 +++ service.go | 1 + service_windows_386.go | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/agent.go b/agent.go index 6b5460f..0441652 100644 --- a/agent.go +++ b/agent.go @@ -2,6 +2,7 @@ package agent import ( "context" + "fmt" "github.com/jkstack/anet" "github.com/jkstack/libagent/conf" @@ -45,6 +46,8 @@ func deferCallback(name string, fn func()) { // RegisterService 注册系统服务 func RegisterService(app App) error { svc := newService(app) + fmt.Printf("service name: %s\n", app.AgentName()) + fmt.Printf("platform: %s\n", svc.Platform()) return svc.Install() } diff --git a/service.go b/service.go index 26b100d..d2e7016 100644 --- a/service.go +++ b/service.go @@ -5,4 +5,5 @@ type builtinService interface { Uninstall() error Run() error Stop() error + Platform() string } diff --git a/service_windows_386.go b/service_windows_386.go index 6a080ee..d8eaa9e 100644 --- a/service_windows_386.go +++ b/service_windows_386.go @@ -133,3 +133,7 @@ func (svr *svr) Execute(args []string, r <-chan svc.ChangeRequest, changes chan< changes <- svc.Status{State: svc.StopPending} return false, 0 } + +func (svr *svr) Platform() string { + return "windows-service" +}