-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
36 lines (30 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"fmt"
"github.com/cloudwego/kitex/server"
"github.com/eyebluecn/sc-misc-idl/kitex_gen/sc_misc_api/miscservice"
"github.com/eyebluecn/sc-misc/src/common/config"
"github.com/eyebluecn/sc-misc/src/handler"
config3 "github.com/eyebluecn/sc-misc/src/infrastructure/rpc/config"
config2 "github.com/eyebluecn/sc-misc/src/repository/config"
"log"
"net"
"time"
)
func main() {
//初始化MySQL
config2.DefaultMysqlConfig().Init()
//自定义端口
addr, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:%v", config.MiscServerPort))
svr := miscservice.NewServer(new(handler.MiscServiceImpl),
server.WithServiceAddr(addr), //地址端口
server.WithReadWriteTimeout(365*24*time.Hour), //一段时间没有读到客户端的请求,就报超时错误,设置1年。 https://developer.aliyun.com/article/1408192
server.WithExitWaitTime(5*time.Second), //Server 在收到退出信号时的等待时间 可理解为优雅关闭连接的时长。
)
//初始化RPC客户端
config3.DefaultMysqlConfig().Init()
err := svr.Run()
if err != nil {
log.Println(err.Error())
}
}