add commit hash to logs

This commit is contained in:
Jesse de Wit
2024-01-26 16:50:51 +01:00
parent be7db07f95
commit 6cbe45629f
3 changed files with 41 additions and 0 deletions

36
build/build.go Normal file
View File

@@ -0,0 +1,36 @@
package build
import "runtime/debug"
var (
tag string
revision string
)
func GetRevision() string {
if revision != "" {
return revision
}
buildInfo, ok := debug.ReadBuildInfo()
if !ok {
return "unknown"
}
for _, setting := range buildInfo.Settings {
if setting.Key == "vcs.revision" {
revision = setting.Value
return revision
}
}
return "unknown"
}
func GetTag() string {
if tag != "" {
return tag
}
return "none"
}

View File

@@ -14,6 +14,8 @@ import (
"strings" "strings"
"sync" "sync"
"time" "time"
"github.com/breez/lspd/build"
) )
const ( const (
@@ -68,6 +70,7 @@ func NewClnPlugin(in, out *os.File) *ClnPlugin {
// NOTE: The grpc server is started in the handleInit function. // NOTE: The grpc server is started in the handleInit function.
func (c *ClnPlugin) Start() { func (c *ClnPlugin) Start() {
c.setupLogging() c.setupLogging()
log.Printf(`Starting lspd cln_plugin, tag='%s', revision='%s'`, build.GetTag(), build.GetRevision())
go c.listenRequests() go c.listenRequests()
<-c.done <-c.done
s := c.server s := c.server

View File

@@ -13,6 +13,7 @@ import (
"syscall" "syscall"
"time" "time"
"github.com/breez/lspd/build"
"github.com/breez/lspd/chain" "github.com/breez/lspd/chain"
"github.com/breez/lspd/cln" "github.com/breez/lspd/cln"
"github.com/breez/lspd/common" "github.com/breez/lspd/common"
@@ -38,6 +39,7 @@ func main() {
return return
} }
log.Printf(`Starting lspd, tag='%s', revision='%s'`, build.GetTag(), build.GetRevision())
n := os.Getenv("NODES") n := os.Getenv("NODES")
var nodeConfigs []*config.NodeConfig var nodeConfigs []*config.NodeConfig
err := json.Unmarshal([]byte(n), &nodeConfigs) err := json.Unmarshal([]byte(n), &nodeConfigs)