package main import ( "flag" "fmt" "git.noahlan.cn/northlan/ntools-go/logger" "live-gateway/bilibili" "live-gateway/config" "sync" "time" ) var configFile = flag.String("f", "./config.yml", "the config file") func main() { flag.Parse() config.Init(*configFile) if err := logger.InitLogger(&config.Config.Log.File, &config.Config.Log.Console); err != nil { fmt.Println("初始化logger错误", err) } defer logger.Sync() var wg sync.WaitGroup if config.Config.Bilibili.Enabled { bLive := bilibili.NewLiveBilibili() wg.Add(1) go func() { if err := bLive.Serve(); err != nil { logger.SLog.Error("err: ", err) wg.Done() } }() go func() { // timer timer := time.NewTimer(time.Second * config.Config.Bilibili.ResetInterval) for { select { case <-timer.C: bLive.ReConnect() } } }() } wg.Wait() }