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.

70 lines
1.5 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"
"runtime"
1 month ago
)
var (
VERSION string
SVN_REVISION string
BUILD_NUMBER string
BUILD_TIME string
GO_VERSION string
)
func logVersions() {
log.Printf("Version:%s", VERSION)
log.Printf("SVN Revision:%s", SVN_REVISION)
log.Printf("Build Number:%s", BUILD_NUMBER)
log.Printf("Build Time:%s", BUILD_TIME)
log.Printf("Go Version:%s", GO_VERSION)
log.Printf("Go OS/Arch:%s/%s", runtime.GOOS, runtime.GOARCH)
log.Println()
}
1 month ago
func main() {
logVersions()
1 month ago
//获取状态集合序号
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
}()
}