Skip to content

Commit

Permalink
feat(config): pass config path to main loop and update handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dido18 committed Jan 22, 2025
1 parent 4f3ac5a commit c41b815
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,11 @@ func main() {
// Check if certificates made with Agent <=1.2.7 needs to be moved over the new location
cert.MigrateCertificatesGeneratedWithOldAgentVersions(config.GetCertificatesDir())

configPath := config.GetConfigPath()
fmt.Println("configPath: ", configPath)

// Launch main loop in a goroutine
go loop()
go loop(configPath)

// SetupSystray is the main thread
configDir := config.GetDefaultConfigDir()
Expand All @@ -156,6 +159,7 @@ func main() {
AdditionalConfig: *additionalConfig,
ConfigDir: configDir,
}
Systray.SetCurrentConfigFile(configPath)

if src, err := os.Executable(); err != nil {
panic(err)
Expand All @@ -166,11 +170,15 @@ func main() {
}
}

func loop() {
func loop(configPath *paths.Path) {
if *hibernate {
return
}

if configPath == nil {
log.Panic("configPath is nil")
}

log.SetLevel(log.InfoLevel)
log.SetOutput(os.Stdout)

Expand All @@ -189,10 +197,6 @@ func loop() {
h.broadcastSys <- mapB
}

configPath := config.GetConfigPath()

fmt.Println("configPath: ", configPath)

// if the default browser is Safari, prompt the user to install HTTPS certificates
// and eventually install them
if runtime.GOOS == "darwin" {
Expand Down Expand Up @@ -230,7 +234,6 @@ func loop() {
if err != nil {
log.Panicf("cannot parse arguments: %s", err)
}
Systray.SetCurrentConfigFile(configPath)

// Parse additional ini config if defined
if len(*additionalConfig) > 0 {
Expand Down

0 comments on commit c41b815

Please sign in to comment.