et-go 20240919重建
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.1 KiB

1 month ago
package main
import (
"gitea.anxinyun.cn/container/common_utils/configLoad"
"log"
etMaster "master/app"
"net/http"
_ "net/http/pprof"
etNode "node/app"
"os"
)
func main() {
//获取状态集合序号
hostName, err := os.Hostname() //"etgo-0"
if err != nil {
log.Printf("Error getting hostname:%s", err.Error())
return
}
masterTag := configLoad.LoadConfig().GetString("master.hostNameTag")
log.Printf("hostName =[%s],masterTag=[%s]", hostName, masterTag)
if hostName == masterTag {
log.Printf("启动类型:master => hostName=[%s]", hostName)
etMaster.Start()
} else {
pprofEnable := configLoad.LoadConfig().GetBool("pprof.enable")
if pprofEnable {
pprofRun()
}
1 month ago
log.Printf("启动类型:node => hostName=[%s]", hostName)
etNode.Start()
}
}
func pprofRun() {
pprofAddr := ":10000"
log.Printf("性能分析 => pprofAddr=[%s]", pprofAddr)
go func() {
err := http.ListenAndServe(pprofAddr, nil)
if err != nil {
log.Panicf("启动异常 => [%s]", err.Error())
} //开启一个http服务,nil表示绑定默认路由器DefaultServeMux
1 month ago
}()
}