1 Star 0 Fork 12

hualaoshi/RunnerGo-collector-open

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
guosongsong 提交于 2023-03-14 14:24 +08:00 . 兼容报告为空的情况
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"
"time"
)
var mode int
var configFile string
func main() {
flag.IntVar(&mode, "m", 0, "读取环境变量还是读取配置文件")
flag.StringVar(&configFile, "c", "./dev.yaml", "配置文件")
if !flag.Parsed() {
flag.Parse()
}
internal.InitProjects(mode, configFile)
runtime.GOMAXPROCS(runtime.NumCPU())
if mode != 0 {
// 检查kafka是否启动
kafkaAddress := os.Getenv("RG_KAFKA_ADDRESS=kafka:9092")
if kafkaAddress == "" {
kafkaAddress = "kafka:9092"
}
time.Sleep(30 * time.Second)
// docker版本,删除上次启动是的
redis.ExitStressBelongPartition(conf.StressBelongPartition)
time.Sleep(60 * time.Second)
}
if mode != 0 {
// 检查kafka是否启动
kafkaAddress := os.Getenv("RG_KAFKA_ADDRESS=kafka:9092")
if kafkaAddress == "" {
kafkaAddress = "kafka:9092"
}
// docker版本,删除上次启动的ip
time.Sleep(30 * time.Second)
redis.ExitStressBelongPartition(conf.StressBelongPartition)
time.Sleep(60 * time.Second)
}
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("注销成功")
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/hualaoshi/runnergo-collector-open.git
[email protected]:hualaoshi/runnergo-collector-open.git
hualaoshi
runnergo-collector-open
RunnerGo-collector-open
open

搜索帮助