19 changed files with 235 additions and 61 deletions
@ -0,0 +1,33 @@
|
||||
[app] |
||||
|
||||
[grpc] |
||||
address = ":7020" |
||||
maxSendMsgSize = "8Mi" |
||||
maxRecvMsgSize = "8Mi" |
||||
readBufferSize = "8Ki" |
||||
writeBufferSize = "8Ki" |
||||
|
||||
[grpc.register.attrs] |
||||
weight = 100 |
||||
|
||||
[etcd] |
||||
endpoints = ["124.222.131.236:3279"] |
||||
username = "root" |
||||
password = "sopod@etcd" |
||||
|
||||
[redis] |
||||
Addr = "124.222.131.236:3379" |
||||
Password = "sopod@redis#" |
||||
DB = 1 |
||||
MinIdleConns = 3 |
||||
|
||||
[gorm] |
||||
logMode=true |
||||
|
||||
[gorm.mysql] |
||||
# https://gorm.io/zh_CN/docs/connecting_to_the_database.html |
||||
DSN = "root:sopod_mysql2347-@tcp(124.222.131.236:3666)/groups?charset=utf8&parseTime=True&loc=Local" |
||||
|
||||
[prometheus] |
||||
enable = false |
||||
port = 7029 |
||||
@ -1,12 +1,35 @@
|
||||
package main |
||||
|
||||
import ( |
||||
"encoding/binary" |
||||
"fmt" |
||||
clientv3 "go.etcd.io/etcd/client/v3" |
||||
"google.golang.org/grpc/grpclog" |
||||
"sonet/internal/auth/logic" |
||||
"sonet/pkg/config" |
||||
"sonet/pkg/grpc/discovery" |
||||
"sonet/pkg/utils/logger" |
||||
"sonet/pkg/utils/shutdown" |
||||
) |
||||
|
||||
func main() { |
||||
buf := make([]byte, 4) |
||||
binary.BigEndian.PutUint32(buf, 12) |
||||
fmt.Printf("%v\n", buf) |
||||
grpclog.SetLoggerV2(logger.Logger) |
||||
|
||||
conf := config.LoadConfig(nil, "cmd/auth") |
||||
|
||||
// registry and run...
|
||||
etcdClient, err := clientv3.New(conf.Etcd) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
|
||||
registry := discovery.NewRegister(etcdClient) |
||||
shutdown.AddShutdownHook(registry.Stop) |
||||
authServer := logic.NewAuthServer() |
||||
go func() { |
||||
err = authServer.Run(conf.Grpc, registry) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
}() |
||||
|
||||
shutdown.Await() |
||||
} |
||||
|
||||
Loading…
Reference in new issue