From a6ea02146867044ef3dda9d2fc8d91a07c7b5633 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Fri, 5 Nov 2021 10:12:02 -0700 Subject: [PATCH] use IsWindowsService to detect if running as service Signed-off-by: James Sturtevant --- exporter.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exporter.go b/exporter.go index 0e37fde1..2b3d42c0 100644 --- a/exporter.go +++ b/exporter.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package main @@ -324,13 +325,13 @@ func main() { initWbem() - isInteractive, err := svc.IsAnInteractiveSession() + isService, err := svc.IsWindowsService() if err != nil { log.Fatal(err) } stopCh := make(chan bool) - if !isInteractive { + if isService { go func() { err = svc.Run(serviceName, &windowsExporterService{stopCh: stopCh}) if err != nil {