Files
full/module/base/ads/cmd/main/main.go

51 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @Author: david.yan(david.yan@qq.com)
* @Date: 2021-11-26 15:25:03
* @Description: 广告服务主程序入口
*/
package main
import (
"bsm/full/module/base/ads/internal/config"
"bsm/full/module/base/ads/internal/impl"
"bsm/full/module/base/ads/internal/server"
"git.apinb.com/bsm-sdk/core/service"
)
var (
ServiceKey = "ads" // 服务标识符
)
// main 广告服务主函数
func Run() {
// 初始化服务配置
config.New(ServiceKey)
// 初始化各类服务实例数据库、缓存、etcd等
impl.NewImpl()
// 创建gRPC服务器实例
s := server.New(nil)
// 创建微服务实例
srv := service.New(
s.Grpc,
&service.Options{
Addr: config.Spec.Addr, // 服务监听地址
MsConf: config.Spec.MicroService, // 微服务配置
EtcdClient: impl.EtcdService, // Etcd客户端
GatewayCtx: s.Ctx, // 网关上下文
GatewayConf: config.Spec.Gateway, // 网关配置
GatewayMux: s.Mux, // 网关路由
},
)
// 优雅关闭服务
defer srv.Stop()
// 启动服务
srv.Start()
}
func main() {
Run()
}