From 9139967bb409ab4dd9b69d62e796a2721f9dc136 Mon Sep 17 00:00:00 2001 From: Zach Wasserman Date: Tue, 24 Sep 2024 18:07:54 -0700 Subject: [PATCH] Move Windows service initialization above patching --- orbit/cmd/orbit/orbit.go | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/orbit/cmd/orbit/orbit.go b/orbit/cmd/orbit/orbit.go index 8c893e26b72b..e1ee46b19f27 100644 --- a/orbit/cmd/orbit/orbit.go +++ b/orbit/cmd/orbit/orbit.go @@ -290,6 +290,22 @@ func main() { reloadLaunchDaemon() } + var ( + g run.Group + appDoneCh chan struct{} // closed when runner run.group.Run() returns + ) + + // Setting up the system service management early on the process lifetime + appDoneCh = make(chan struct{}) + + // Initializing windows service runner and system service manager. + if runtime.GOOS == "windows" { + systemChecker := newSystemChecker() + addSubsystem(&g, "system checker", systemChecker) + go osservice.SetupServiceManagement(constant.SystemServiceName, systemChecker.svcInterruptCh, appDoneCh) + time.Sleep(1 * time.Second) + } + checkAndPatchCertificate(c.String("root-dir")) // Override flags with values retrieved from Fleet. @@ -473,20 +489,8 @@ func main() { var ( osquerydPath string desktopPath string - g run.Group - appDoneCh chan struct{} // closed when runner run.group.Run() returns ) - // Setting up the system service management early on the process lifetime - appDoneCh = make(chan struct{}) - - // Initializing windows service runner and system service manager. - if runtime.GOOS == "windows" { - systemChecker := newSystemChecker() - addSubsystem(&g, "system checker", systemChecker) - go osservice.SetupServiceManagement(constant.SystemServiceName, systemChecker.svcInterruptCh, appDoneCh) - } - // sofwareupdated is a macOS daemon that automatically updates Apple software. if c.Bool("disable-kickstart-softwareupdated") && runtime.GOOS == "darwin" { log.Warn().Msg("fleetd no longer automatically kickstarts softwareupdated. The --disable-kickstart-softwareupdated flag, which was previously used to disable this behavior, has been deprecated and will be removed in a future version")