package main

import (
	"fmt"
	"fonchain-artshow/cmd/controller"
	grpc2 "fonchain-artshow/pb/grpc"
	"net"

	"google.golang.org/grpc"

	"fonchain-artshow/pkg/db"
	"fonchain-artshow/pkg/logger"
	"fonchain-artshow/pkg/m"
)

type server struct {
	grpc2.UnimplementedArtShowServer
}

func main() {
	l, err := net.Listen("tcp", ":8883")
	if err != nil {
		fmt.Printf("failed to listen: %v", err)
		return
	}

	s := grpc.NewServer()                                         // 创建gRPC服务器
	grpc2.RegisterArtShowServer(s, &controller.ArtShowProvider{}) // 在gRPC服务端注册服务

	db.Init(m.SERVER_CONFIG)
	//初始化zap
	logger.ZapInit(m.SERVER_CONFIG)

	//demo.InitLogger()
	//defer demo.SugarLogger.Sync()

	// 启动服务
	err = s.Serve(l)
	if err != nil {
		fmt.Printf("failed to serve: %v", err)
		return
	}
}
