categraf/main_windows.go

22 lines
394 B
Go
Raw Normal View History

2022-05-29 17:03:03 +08:00
//go:build windows
// +build windows
package main
import (
"flashcat.cloud/categraf/agent"
"github.com/chai2010/winsvc"
)
func runAgent(ag *agent.Agent) {
if !winsvc.IsAnInteractiveSession() {
if err := winsvc.RunAsService(*flagWinSvcName, ag.Start, ag.Stop, false); err != nil {
log.Fatalln("F! failed to run windows service:", err)
}
return
}
ag.Start()
handleSignal(ag)
}