proto/goutils/proto_build/tpls/main.tpl

40 lines
798 B
Smarty
Raw Normal View History

2023-11-27 09:36:02 +00:00
package main
import (
"fmt"
"net"
"fusen-basic/env"
"fusen-basic/utils/log"
"{{.ProjectName}}/gen/go/service"
"{{.ProjectName}}/server/config"
{{range .LogicDirNames}}
"{{$.ProjectName}}/{{.}}"
{{- end}}
"google.golang.org/grpc"
)
func main() {
fusen := env.NewFusen[config.Config]()
fusen.StartNacos(nil)
service.AutoGrpcInit(fusen)
sopt := grpc.UnaryInterceptor(fusen.Interceptor())
lis, err := net.Listen("tcp", fmt.Sprintf(":%d", fusen.ServiceConfig.Port)) //开启监听
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
s := grpc.NewServer(sopt) //新建一个grpc服务
2023-12-04 09:15:41 +00:00
MainRegisterServer(s) // 注册所有的service
2023-11-27 09:36:02 +00:00
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}