2022-05-29 17:03:03 +08:00
|
|
|
//go:build windows
|
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2022-05-29 17:16:16 +08:00
|
|
|
"log"
|
|
|
|
|
2022-05-29 17:03:03 +08:00
|
|
|
"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)
|
|
|
|
}
|