1 Star 0 Fork 12

Leo/RunnerGo-collector-open

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 1.96 KB
一键复制 编辑 原始数据 按行查看 历史
guosongsong 提交于 2023-05-08 14:25 . 修改rps算法(验证)
package main
import (
"flag"
"github.com/Runner-Go-Team/RunnerGo-collector-open/internal"
"github.com/Runner-Go-Team/RunnerGo-collector-open/internal/pkg/conf"
"github.com/Runner-Go-Team/RunnerGo-collector-open/internal/pkg/dal/redis"
log2 "github.com/Runner-Go-Team/RunnerGo-collector-open/internal/pkg/log"
"github.com/Runner-Go-Team/RunnerGo-collector-open/internal/pkg/server"
"github.com/pyroscope-io/client/pyroscope"
"net/http"
"os"
"os/signal"
"runtime"
"syscall"
"time"
)
var mode int
var configFile string
func main() {
flag.IntVar(&mode, "m", 0, "读取环境变量还是读取配置文件")
flag.StringVar(&configFile, "c", "./open.yaml", "配置文件")
if !flag.Parsed() {
flag.Parse()
}
internal.InitProjects(mode, configFile)
runtime.GOMAXPROCS(runtime.NumCPU())
// 性能分析
pyroscope.Start(
pyroscope.Config{
ApplicationName: "RunnerGo-engine-open",
ServerAddress: "http://192.168.1.205:4040/",
//Logger: pyroscope.StandardLogger,
ProfileTypes: []pyroscope.ProfileType{
pyroscope.ProfileCPU,
pyroscope.ProfileAllocObjects,
pyroscope.ProfileAllocSpace,
pyroscope.ProfileInuseObjects,
pyroscope.ProfileInuseSpace,
},
})
// 发送心跳
go redis.SendHeartBeatRedis(conf.Collector, conf.Duration)
if mode != 0 {
// 检查kafka是否启动
kafkaAddress := os.Getenv("RG_KAFKA_ADDRESS")
if kafkaAddress == "" {
kafkaAddress = "kafka:9092"
}
time.Sleep(60 * time.Second)
// docker版本,删除上次启动是的
redis.ExitStressBelongPartition(conf.StressBelongPartition, conf.Collector)
}
collectorService := &http.Server{
Addr: conf.Conf.Http.Host,
}
go server.Execute(conf.Conf.Kafka.Host)
go func() {
if err := collectorService.ListenAndServe(); err != nil {
log2.Logger.Error("collector:", err)
return
}
}()
/// 接收终止信号
quit := make(chan os.Signal)
signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM)
<-quit
log2.Logger.Info("注销成功")
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/Leo210923/runnergo-collector-open.git
git@gitee.com:Leo210923/runnergo-collector-open.git
Leo210923
runnergo-collector-open
RunnerGo-collector-open
open

搜索帮助