refactor: reorganize modules and add Linux build tooling
This commit is contained in:
8
module/base/ads/cmd/cli/main.go
Normal file
8
module/base/ads/cmd/cli/main.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
import "log"
|
||||
|
||||
// main 命令行工具入口函数
|
||||
func main() {
|
||||
log.Println("广告服务命令行工具")
|
||||
}
|
||||
50
module/base/ads/cmd/main/main.go
Normal file
50
module/base/ads/cmd/main/main.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @Author: david.yan(david.yan@qq.com)
|
||||
* @Date: 2021-11-26 15:25:03
|
||||
* @Description: 广告服务主程序入口
|
||||
*/
|
||||
package service
|
||||
|
||||
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(config.Spec.Addr)
|
||||
// 创建微服务实例
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user