From 44f4918219f965f12e2046164c6154cd1bb5c1f1 Mon Sep 17 00:00:00 2001 From: Dinifarb Date: Sun, 7 Jan 2024 13:24:51 +0100 Subject: [PATCH 1/2] fix(#1352): moving the stop signal after svc.Run() Signed-off-by: Dinifarb --- pkg/initiate/initiate.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/initiate/initiate.go b/pkg/initiate/initiate.go index 00162dd4..04b97561 100644 --- a/pkg/initiate/initiate.go +++ b/pkg/initiate/initiate.go @@ -13,9 +13,7 @@ const ( serviceName = "windows_exporter" ) -type windowsExporterService struct { - stopCh chan<- bool -} +type windowsExporterService struct{} var logger *eventlog.Log @@ -39,7 +37,6 @@ loop: } } } - s.stopCh <- true return } @@ -63,10 +60,13 @@ func init() { } _ = logger.Info(100, "Attempting to start exporter service") go func() { - err = svc.Run(serviceName, &windowsExporterService{stopCh: StopCh}) + err = svc.Run(serviceName, &windowsExporterService{}) if err != nil { _ = logger.Error(102, fmt.Sprintf("Failed to start service: %v", err)) } + defer func() { + StopCh <- true + }() }() } } From 3868c976869e9830cfdaa31f1a874c31a227e90f Mon Sep 17 00:00:00 2001 From: DiniFarb Date: Tue, 9 Jan 2024 12:40:01 +0100 Subject: [PATCH 2/2] Update pkg/initiate/initiate.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jan-Otto Kröpke Signed-off-by: DiniFarb --- pkg/initiate/initiate.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/initiate/initiate.go b/pkg/initiate/initiate.go index 04b97561..399e978d 100644 --- a/pkg/initiate/initiate.go +++ b/pkg/initiate/initiate.go @@ -64,9 +64,7 @@ func init() { if err != nil { _ = logger.Error(102, fmt.Sprintf("Failed to start service: %v", err)) } - defer func() { - StopCh <- true - }() + StopCh <- true }() } }