33 lines
672 B
Smarty
33 lines
672 B
Smarty
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net"
|
|
"fusen-basic/env"
|
|
"fusen-basic/utils/log"
|
|
|
|
"{{.ProjectName}}/server/config"
|
|
|
|
"google.golang.org/grpc"
|
|
)
|
|
|
|
func main() {
|
|
|
|
fusen := env.NewFusen[config.Config]()
|
|
fusen.StartNacosGRPC(nil)
|
|
|
|
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服务
|
|
|
|
MainRegisterServer(s) // 注册所有的service
|
|
|
|
if err := s.Serve(lis); err != nil {
|
|
log.Fatalf("failed to serve: %v", err)
|
|
}
|
|
}
|