Skip to content

Commit

Permalink
fix config name
Browse files Browse the repository at this point in the history
  • Loading branch information
mazrean committed Aug 9, 2024
1 parent 828426f commit 013e61b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 10 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
)

var (
Enable = true
HostName string
Enable = true
Host string
Addr = ":6060"
)

func init() {
Expand All @@ -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
}
}
4 changes: 2 additions & 2 deletions profiler/pyroscope.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
10 changes: 2 additions & 8 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package isutools
import (
"log"
"net/http"
"os"

_ "net/http/pprof"

Expand All @@ -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)
}
}()
}

0 comments on commit 013e61b

Please sign in to comment.