Skip to content

Commit

Permalink
log root directory changes to debug.json
Browse files Browse the repository at this point in the history
  • Loading branch information
zackattack01 committed Jun 7, 2024
1 parent cdf6a57 commit 447fe39
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions cmd/launcher/svc_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro
logger := log.NewNopLogger()

if opts.RootDirectory != "" {
rootDirectoryChanged := false
optsRootDirectory := opts.RootDirectory
// check for old root directories before creating DB in case we've stomped over with windows MSI install
updatedRootDirectory := determineRootDirectory(systemSlogger.Logger, opts)
if updatedRootDirectory != opts.RootDirectory {
systemSlogger.Log(context.TODO(), slog.LevelInfo,
"old root directory contents detected, overriding opts.RootDirectory",
"opts_root_directory", opts.RootDirectory,
"updated_root_directory", updatedRootDirectory,
)

opts.RootDirectory = updatedRootDirectory
// cache that we did this so we can log to debug.json when set up below
rootDirectoryChanged = true
}

// Create a local logger. This logs to a known path, and aims to help diagnostics
Expand All @@ -80,6 +78,14 @@ func runWindowsSvc(systemSlogger *multislogger.MultiSlogger, args []string) erro

// also write system logs to localSloggerHandler
systemSlogger.AddHandler(localSloggerHandler)

if rootDirectoryChanged {
localSlogger.Log(context.TODO(), slog.LevelInfo,
"old root directory contents detected, overriding opts.RootDirectory",
"opts_root_directory", optsRootDirectory,
"updated_root_directory", updatedRootDirectory,
)
}
}

// Confirm that service configuration is up-to-date
Expand Down

0 comments on commit 447fe39

Please sign in to comment.