1
All checks were successful
Auth & User Management Service CI / build-services (app/auth_service/Dockerfile, auth_service, auth_service) (push) Successful in 40s
Auth & User Management Service CI / build-services (app/douyin_ecpm_calculation_service/Dockerfile, douyin_ecpm_calculation_service, douyin_ecpm_calculation_service) (push) Successful in 38s
Auth & User Management Service CI / build-services (app/ranking_management/Dockerfile, ranking_management, ranking_management) (push) Successful in 42s
Auth & User Management Service CI / build-services (app/user_management/Dockerfile, user_manager, user_management) (push) Successful in 39s
Auth & User Management Service CI / start-services (push) Successful in 4s

This commit is contained in:
xiabin 2025-02-11 16:54:00 +08:00
parent d04175ee7c
commit c7f5f9828a
4 changed files with 22 additions and 11 deletions

View File

@ -4,24 +4,28 @@ import (
"flag"
"fmt"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/douyin_ecpm_calculation_service/douyin_ecpm_calculation_service"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/douyin_ecpm_calculation_service/internal/config"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/douyin_ecpm_calculation_service/internal/server"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/douyin_ecpm_calculation_service/internal/svc"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/pkg/config"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/service"
"github.com/zeromicro/go-zero/zrpc"
"google.golang.org/grpc"
"google.golang.org/grpc/reflection"
)
var configFile = flag.String("f", "etc/douyin_ecpm_calculation_service.yaml", "the config file")
const ServiceName = "douyin_ecpm"
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
err := config.GetConfig(&c, ServiceName)
if err != nil {
panic(err)
}
c.RpcServerConf.Name = ServiceName + ".rpc"
ctx := svc.NewServiceContext(c)
s := zrpc.MustNewServer(c.RpcServerConf, func(grpcServer *grpc.Server) {
@ -31,8 +35,9 @@ func main() {
reflection.Register(grpcServer)
}
})
defer s.Stop()
fmt.Printf("Starting rpc server at %s...\n", c.ListenOn)
fmt.Printf("Starting rpc server at %s...\n", c.RpcServerConf.ListenOn)
s.Start()
}

View File

@ -3,7 +3,8 @@ package svc
import (
"context"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/auth_service/auth_service"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/app/douyin_ecpm_calculation_service/internal/config"
"gitea.youtukeji.com.cn/xiabin/youtu_grpc/pkg/config"
"github.com/spf13/viper"
"github.com/zeromicro/go-zero/core/conf"
"github.com/zeromicro/go-zero/core/discov"
"github.com/zeromicro/go-zero/zrpc"
@ -36,7 +37,7 @@ const EcpmConfigWatchKey = "ecpm_config"
func (svc *ServiceContext) initEtcd() {
//初始化etcd客户端
cli, err := clientv3.NewFromURL(svc.Config.Etcd.Hosts[0])
cli, err := clientv3.NewFromURL(viper.GetString(config.EtcdAddrKey))
if err != nil {
panic(err)
}
@ -77,7 +78,7 @@ func (svc *ServiceContext) initAuthServiceClient() {
clientConf.Token = "auth_service.rpc.key"
clientConf.App = "auth_service.rpc"
clientConf.Etcd = discov.EtcdConf{ // 通过 etcd 服务发现
Hosts: svc.Config.Etcd.Hosts,
Hosts: []string{viper.GetString(config.EtcdAddrKey)},
Key: "auth_service.rpc",
}

View File

@ -48,6 +48,11 @@ func GetConfig(c *Config, serverName string) (err error) {
if err != nil {
return
}
return viper.Unmarshal(&c)
err = viper.Unmarshal(&c)
if err != nil {
return
}
c.RpcServerConf.Name = serverName + ".rpc"
c.RpcServerConf.ServiceConf.Mode = c.Mode
return
}

View File

@ -33,7 +33,7 @@ func TestGenConfig(t *testing.T) {
c.RpcServerConf.ListenOn = "0.0.0.0:8081"
c.Mode = "dev"
c.Mysql = "root:youtu!0113@tcp(192.168.0.47:3306)/ecpm?charset=utf8mb4&parseTime=True&loc=Local"
c.Redis = []Redis{{Host: "192.168.0.47:2379:6379"}}
c.Redis = []Redis{{Host: "192.168.0.47:6379"}}
c.RpcServerConf.Etcd.Hosts = append(c.RpcServerConf.Etcd.Hosts, "192.168.0.47:2379")
c.RpcServerConf.Etcd.Key = "user_management.rpc"
b, err := json.Marshal(c)