2 Star 5 Fork 9

RunnerGo / RunnerGo-collector-open

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 1.94 KB
一键复制 编辑 原始数据 按行查看 历史
guosongsong 提交于 2023-08-24 15:49 . 优化报告处理
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"
"net/http"
"os"
"os/signal"
"runtime"
"syscall"
)
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-collector-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("注销成功")
}
Go
1
https://gitee.com/Runner-Go-Team/runnergo-collector-open.git
git@gitee.com:Runner-Go-Team/runnergo-collector-open.git
Runner-Go-Team
runnergo-collector-open
RunnerGo-collector-open
open

搜索帮助