From a0e1f79685d0f046f1df964a0bc4e25eaa6e3be4 Mon Sep 17 00:00:00 2001 From: Michal Pristas Date: Thu, 20 Jun 2024 14:39:45 +0200 Subject: [PATCH] conflicts --- internal/pkg/agent/appinit/appinit.go | 17 ++++++++++------- main.go | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/internal/pkg/agent/appinit/appinit.go b/internal/pkg/agent/appinit/appinit.go index 82c7e8fd51f..149cda9d381 100644 --- a/internal/pkg/agent/appinit/appinit.go +++ b/internal/pkg/agent/appinit/appinit.go @@ -11,18 +11,21 @@ import ( ) var stopSvcChan = make(chan bool) +var once sync.Once var stopBeat = func() { close(stopSvcChan) } func init() { - var wg sync.WaitGroup - wg.Add(1) - go func() { - wg.Done() - service.ProcessWindowsControlEvents(stopBeat) - }() - wg.Wait() + once.Do(func() { + var wg sync.WaitGroup + wg.Add(1) + go func() { + wg.Done() + service.ProcessWindowsControlEvents(stopBeat) + }() + wg.Wait() + }) } func StopSvcChan() chan bool { diff --git a/main.go b/main.go index 98580c51c5b..9adea7ce236 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "os" "time" + _ "github.com/elastic/elastic-agent/internal/pkg/agent/appinit" "github.com/elastic/elastic-agent/internal/pkg/agent/cmd" "github.com/elastic/elastic-agent/pkg/core/process" )