From 4add010b8da8d4705a6b0bbd159f8eb70807e04d Mon Sep 17 00:00:00 2001 From: Dinifarb Date: Tue, 22 Aug 2023 16:53:19 +0200 Subject: [PATCH] fix: Windows service can't stop without an error #1258 Signed-off-by: Dinifarb --- initiate/initiate.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/initiate/initiate.go b/initiate/initiate.go index 2f66d8f6..0c0453cb 100644 --- a/initiate/initiate.go +++ b/initiate/initiate.go @@ -32,14 +32,14 @@ loop: changes <- c.CurrentStatus case svc.Stop, svc.Shutdown: _ = logger.Info(100, "Service Stop Received") - s.stopCh <- true + changes <- svc.Status{State: svc.StopPending} break loop default: _ = logger.Error(102, fmt.Sprintf("unexpected control request #%d", c)) } } } - changes <- svc.Status{State: svc.StopPending} + s.stopCh <- true return } @@ -57,7 +57,7 @@ func init() { } if isService { - logger, err := eventlog.Open("windows_exporter") + logger, err = eventlog.Open("windows_exporter") if err != nil { os.Exit(2) }