package main import ( "gitea.timerzz.com/kedaya_haitao/pusher/biz/dal" "gitea.timerzz.com/kedaya_haitao/pusher/pushers" "net" "time" "gitea.timerzz.com/kedaya_haitao/pusher/conf" "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push/pushservice" "github.com/cloudwego/kitex/pkg/klog" "github.com/cloudwego/kitex/pkg/rpcinfo" "github.com/cloudwego/kitex/pkg/transmeta" "github.com/cloudwego/kitex/server" kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" "go.uber.org/zap/zapcore" "gopkg.in/natefinch/lumberjack.v2" ) func main() { dal.Init() pushers.Init() opts := kitexInit() svr := pushservice.NewServer(new(PushServiceImpl), opts...) err := svr.Run() if err != nil { klog.Error(err.Error()) } } func kitexInit() (opts []server.Option) { opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) opts = append(opts, server. WithTransHandlerFactory(&mixTransHandlerFactory{nil})) // address addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address) if err != nil { panic(err) } opts = append(opts, server.WithServiceAddr(addr)) // service info opts = append(opts, server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ ServiceName: conf.GetConf().Kitex.Service, })) // thrift meta handler opts = append(opts, server.WithMetaHandler(transmeta.ServerTTHeaderHandler)) // klog logger := kitexlogrus.NewLogger() klog.SetLogger(logger) klog.SetLevel(conf.LogLevel()) asyncWriter := &zapcore.BufferedWriteSyncer{ WS: zapcore.AddSync(&lumberjack.Logger{ Filename: conf.GetConf().Kitex.LogFileName, MaxSize: conf.GetConf().Kitex.LogMaxSize, MaxBackups: conf.GetConf().Kitex.LogMaxBackups, MaxAge: conf.GetConf().Kitex.LogMaxAge, }), FlushInterval: time.Minute, } klog.SetOutput(asyncWriter) server.RegisterShutdownHook(func() { asyncWriter.Sync() }) return }