From 892da5dc223d30e064216f32c3db15a1b8853307 Mon Sep 17 00:00:00 2001 From: dvovk Date: Fri, 31 May 2024 15:46:34 +0100 Subject: [PATCH 1/2] added info about diagnostics UI version, removed autorun for ui --- cmd/diagnostics/main.go | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/cmd/diagnostics/main.go b/cmd/diagnostics/main.go index d6702e7..4d1a830 100644 --- a/cmd/diagnostics/main.go +++ b/cmd/diagnostics/main.go @@ -1,14 +1,14 @@ package main import ( + "bufio" "context" "fmt" "log" "net/http" "os" - "os/exec" "os/signal" - "runtime" + "strings" "syscall" "time" @@ -59,7 +59,14 @@ func main() { } }() - open(fmt.Sprintf("http://%s:%d", listenAddr, listenPort)) + packagePath := "github.com/ledgerwatch/erigonwatch" + version, err := GetPackageVersion(packagePath) + if err == nil { + fmt.Printf("Diagnostics version: %s\n", version) + } + + fmt.Printf("Diagnostics UI is running on http://%s:%d\n", listenAddr, listenPort) + //open(fmt.Sprintf("http://%s:%d", listenAddr, listenPort)) // Graceful and eager terminations switch s := <-signalCh; s { @@ -75,7 +82,7 @@ func main() { } // open opens the specified URL in the default browser of the user. -func open(url string) error { +/*func open(url string) error { var cmd string var args []string @@ -90,4 +97,26 @@ func open(url string) error { } args = append(args, url) return exec.Command(cmd, args...).Start() +}*/ + +// GetPackageVersion returns the version of a package from the go.mod file. +func GetPackageVersion(packagePath string) (string, error) { + file, err := os.Open("./../../go.mod") + if err != nil { + return "", fmt.Errorf("failed to open go.mod file: %w", err) + } + defer file.Close() + + scanner := bufio.NewScanner(file) + for scanner.Scan() { + line := scanner.Text() + if strings.HasPrefix(line, "\t"+packagePath+" ") { + // Extract the version from the line + split := strings.Split(line, " ") + version := strings.TrimSpace(split[1]) + return version, nil + } + } + + return "", fmt.Errorf("package not found in go.mod file: %s", packagePath) } From c48865b3833f20a84e0fd693854c6d36e28e86c4 Mon Sep 17 00:00:00 2001 From: dvovk Date: Fri, 31 May 2024 16:08:36 +0100 Subject: [PATCH 2/2] updated docs --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37b73b1..908de29 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ cd diagnostics make build ``` -Run the application. This may take a while. Expect to see a TLS Handshake error in the terminal +Run the application. ``` make run-self-signed ``` @@ -131,6 +131,8 @@ make run-self-signed [Diagnostics setup](#diagnostics-set-up) #### Step 2: +Open UI application in browser, you will find the link to it in console. + Follow these steps to create a session: ![create new operation session 1](/_images/create_session_1.png)