refactor: reorganize modules and add Linux build tooling
This commit is contained in:
48
module/base/initial/cmd/main/main.go
Normal file
48
module/base/initial/cmd/main/main.go
Normal file
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @Author: david.yan(david.yan@qq.com)
|
||||
* @Date: 2021-11-26 15:25:03
|
||||
*/
|
||||
package service
|
||||
|
||||
import (
|
||||
"bsm/full/module/base/initial/internal/config"
|
||||
"bsm/full/module/base/initial/internal/impl"
|
||||
"bsm/full/module/base/initial/internal/server"
|
||||
"git.apinb.com/bsm-sdk/core/service"
|
||||
)
|
||||
|
||||
var (
|
||||
ServiceKey = "Initial"
|
||||
)
|
||||
|
||||
func Run() {
|
||||
// 初始化配置,传入服务标识
|
||||
config.New(ServiceKey)
|
||||
// 初始化实现层(如数据库、缓存等服务)
|
||||
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