edb/main.go

35 lines
506 B
Go
Raw Normal View History

2020-03-04 10:09:19 +00:00
package main
import (
"log"
"net"
"runtime"
2020-03-04 21:12:38 +00:00
proto "edb/goproto"
2020-03-04 10:09:19 +00:00
grpc "google.golang.org/grpc"
)
const (
port = "20051"
)
func CreateServer() {
//起服务
listen, err := net.Listen("tcp", "localhost:"+port)
if err != nil {
log.Fatalf("failed to listen: %v", err)
}
gserver := grpc.NewServer()
2020-03-04 21:12:38 +00:00
proto.RegisterEasyDataServer(gserver, &server{})
2020-03-04 10:09:19 +00:00
gserver.Serve(listen)
// time.Sleep(time.Millisecond * 50)
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
2020-03-04 21:12:38 +00:00
// test.
2020-03-04 10:09:19 +00:00
CreateServer()
2020-03-04 21:12:38 +00:00
2020-03-04 10:09:19 +00:00
}