mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
d475bab15f
To expose context flags through diagnostic endpoint `/debug/metrics/flags`. The current `/debug/metrics/cmdline` only provides the command run by user. In the case when user runs Erigon using config file, `cmdline`’s info does not truly reflect the ‘launch setting' and flags set that Erigon is running on. ## Example ### Command ``` erigon --datadir /tmp/data --config test.yaml ``` ### Pseudo config file (in yaml) ``` datadir : '/tmp/data' chain : "sepolia" http : true metrics: true private.api.addr : "localhost:9090" http.api : ["eth","debug","net"] ``` ### Output ``` SUCCESS chain=sepolia config=test.yaml datadir=/tmp/data http=true http.api=eth,debug,net metrics=true private.api.addr=localhost:9090 ```
26 lines
501 B
Go
26 lines
501 B
Go
package diagnostics
|
|
|
|
import (
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/ledgerwatch/erigon/params"
|
|
)
|
|
|
|
const Version = 2
|
|
|
|
func SetupVersionAccess() {
|
|
http.HandleFunc("/debug/metrics/version", func(w http.ResponseWriter, r *http.Request) {
|
|
w.Header().Set("Access-Control-Allow-Origin", "*")
|
|
writeVersion(w)
|
|
})
|
|
}
|
|
|
|
func writeVersion(w io.Writer) {
|
|
fmt.Fprintf(w, "SUCCESS\n")
|
|
fmt.Fprintf(w, "%d\n", Version)
|
|
fmt.Fprintf(w, "%s\n", params.VersionWithMeta)
|
|
fmt.Fprintf(w, "%s\n", params.GitCommit)
|
|
}
|