add: grpc server port config

This commit is contained in:
viletyy 2021-06-19 22:42:11 +08:00
parent f44beb9900
commit dd3e27e3d6
3 changed files with 6 additions and 3 deletions

View File

@ -13,6 +13,7 @@ app:
upload_image_allow_exts: ['.jpg','.jpeg','.png'] upload_image_allow_exts: ['.jpg','.jpeg','.png']
server: server:
http_port: 8000 http_port: 8000
rpc_port: 8001
read_timeout: 60 read_timeout: 60
write_timeout: 60 write_timeout: 60
tracer_host_port: '127.0.0.1:6831' tracer_host_port: '127.0.0.1:6831'

View File

@ -1,13 +1,14 @@
/* /*
* @Date: 2021-03-22 09:54:07 * @Date: 2021-03-22 09:54:07
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-14 20:40:49 * @LastEditTime: 2021-06-19 22:38:44
* @FilePath: /potato/config/server.go * @FilePath: /potato/config/server.go
*/ */
package config package config
type Server struct { type Server struct {
HttpPort int64 `mapstructure:"http_port" json:"http_port" yaml:"http_port"` HttpPort int64 `mapstructure:"http_port" json:"http_port" yaml:"http_port"`
RpcPort int64 `mapstructure:"rpc_port" json:"rpc_port" yaml:"rpc_port"`
ReadTimeout int64 `mapstructure:"read_timeout" json:"read_timeout" yaml:"read_timeout"` ReadTimeout int64 `mapstructure:"read_timeout" json:"read_timeout" yaml:"read_timeout"`
WriteTimeout int64 `mapstructure:"write_timeout" json:"write_timeout" yaml:"write_timeout"` WriteTimeout int64 `mapstructure:"write_timeout" json:"write_timeout" yaml:"write_timeout"`
TracerHostPort string `mapstructure:"tracer_host_port" json:"tracer_host_port" yaml:"tracer_host_port"` TracerHostPort string `mapstructure:"tracer_host_port" json:"tracer_host_port" yaml:"tracer_host_port"`

View File

@ -1,7 +1,7 @@
/* /*
* @Date: 2021-06-17 00:19:32 * @Date: 2021-06-17 00:19:32
* @LastEditors: viletyy * @LastEditors: viletyy
* @LastEditTime: 2021-06-17 00:33:38 * @LastEditTime: 2021-06-19 22:41:24
* @FilePath: /potato/initialize/grpc.go * @FilePath: /potato/initialize/grpc.go
*/ */
package initialize package initialize
@ -12,6 +12,7 @@ import (
"github.com/viletyy/potato/global" "github.com/viletyy/potato/global"
pb "github.com/viletyy/potato/proto/basic" pb "github.com/viletyy/potato/proto/basic"
"github.com/viletyy/potato/server/basic" "github.com/viletyy/potato/server/basic"
"github.com/viletyy/yolk/convert"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/reflection" "google.golang.org/grpc/reflection"
) )
@ -22,7 +23,7 @@ func RunGrpc() {
reflection.Register(server) reflection.Register(server)
go func() { go func() {
listen, err := net.Listen("tcp", ":10002") listen, err := net.Listen("tcp", ":"+convert.ToString(global.GO_CONFIG.Server.RpcPort))
if err != nil { if err != nil {
global.GO_LOG.Sugar().Fatalf("net.Listen err: %v", err) global.GO_LOG.Sugar().Fatalf("net.Listen err: %v", err)
} }