Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion cmd/templates/web/conf/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
{
"server": {
"ip":"0.0.0.0",
"port": 8080
"port": 8080,
"pprofPort": 8089
},
"metric": {
"pprofAddr": "127.0.0.1",
"pprofPort": 8089,
"prometheusNetType": "tcp",
"prometheusAddr": "127.0.0.1:8090"
}
}
3 changes: 2 additions & 1 deletion cmd/templates/web/conf/configPrd.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"server": {
"ip":"0.0.0.0",
"port": 8080
"port": 8080,
"pprofPort": 8089
}
}
20 changes: 20 additions & 0 deletions cmd/templates/web/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ package main

import (
"flag"
"fmt"
"net"
"xframe/cmd"
"xframe/cmd/templates/web/handler"
"xframe/config"
"xframe/log"
"xframe/metric"
"xframe/server"
)

Expand All @@ -25,6 +29,22 @@ func main() {
panic(err)
}
config.DumpConfigContent()
pprofAddr, _ := config.GetConfigByKey("server.pprofAddr")
pprofPort, _ := config.GetConfigByKey("server.pprofPort")

go func() {
pprof := fmt.Sprintf("%s:%d", pprofAddr, pprofPort)
log.INFOF("start to initialize metric at %s", pprof)
metric.InitPprof(pprof)
}()

prometheusNet, _ := config.GetConfigByKey("metric.prometheusNetType")
prometheusAddr, _ := config.GetConfigByKey("metric.prometheusAddr")
if l, err := net.Listen(prometheusNet.(string), prometheusAddr.(string)); err != nil {
panic(err)
} else {
metric.ServePrometheus(l)
}

addr, _ := config.GetConfigByKey("server.ip")
port, _ := config.GetConfigByKey("server.port")
Expand Down