build: Append commit hash to the main LND context

It can be disabled via the new `logging.no-commit-hash` config option.
This commit is contained in:
Elle Mouton
2024-11-27 10:03:10 +02:00
parent efe08b836e
commit 755ad49440
5 changed files with 47 additions and 6 deletions

13
lnd.go
View File

@@ -155,6 +155,15 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
}
}()
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
ctx, err := build.WithBuildInfo(ctx, cfg.LogConfig)
if err != nil {
return fmt.Errorf("unable to add build info to context: %w",
err)
}
mkErr := func(format string, args ...interface{}) error {
ltndLog.Errorf("Shutting down because error in main "+
"method: "+format, args...)
@@ -188,10 +197,6 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
strings.Title(BitcoinChainName), network,
)
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
// Enable http profiling server if requested.
if cfg.Pprof.Profile != "" {
// Create the http handler.