diff --git a/internal/config/config.go b/internal/config/config.go index 373aced..ddfbdf1 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,8 +8,9 @@ import ( ) var ( - Enable = true - HostName string + Enable = true + Host string + Addr = ":6060" ) func init() { @@ -24,8 +25,13 @@ func init() { Enable = enable } - hostName, ok := os.LookupEnv("HOST_NAME") + host, ok := os.LookupEnv("ISUTOOLS_HOST_NAME") if ok { - HostName = hostName + Host = host + } + + addr, ok := os.LookupEnv("ISUTOOLS_ADDR") + if ok { + Addr = addr } } diff --git a/profiler/pyroscope.go b/profiler/pyroscope.go index 934def7..adeb0c8 100644 --- a/profiler/pyroscope.go +++ b/profiler/pyroscope.go @@ -57,8 +57,8 @@ func init() { func pyroscopeStart() error { tagMap := map[string]string{} - if config.HostName != "" { - tagMap["hostname"] = config.HostName + if config.Host != "" { + tagMap["hostname"] = config.Host } _, err := pyroscope.Start(pyroscope.Config{ diff --git a/server.go b/server.go index 006a9a9..9f03818 100644 --- a/server.go +++ b/server.go @@ -3,7 +3,6 @@ package isutools import ( "log" "net/http" - "os" _ "net/http/pprof" @@ -17,23 +16,18 @@ func init() { return } - addr, ok := os.LookupEnv("ISUTOOL_ADDR") - if !ok { - addr = ":6060" - } - mux := http.NewServeMux() profiler.Register(mux) benchmark.Register(mux) go func() { server := http.Server{ - Addr: addr, + Addr: config.Addr, Handler: mux, } err := server.ListenAndServe() if err != nil { - log.Printf("failed to listen and serve(%s): %v", addr, err) + log.Printf("failed to listen and serve(%s): %v", config.Addr, err) } }() }