added min-rpc-ping-interval under app to the server configuration
This commit is contained in:
@@ -104,6 +104,7 @@ type ServerAppConfig struct {
|
|||||||
LogRotate int `yaml:"log-rotate"`
|
LogRotate int `yaml:"log-rotate"`
|
||||||
MaxPeers int `yaml:"max-peer-conns"` // maximum number of connections from peers
|
MaxPeers int `yaml:"max-peer-conns"` // maximum number of connections from peers
|
||||||
MaxRpcConns int `yaml:"max-rpc-conns"` // maximum number of rpc connections
|
MaxRpcConns int `yaml:"max-rpc-conns"` // maximum number of rpc connections
|
||||||
|
MinRpcPingIntvl time.Duration `yaml:"min-rpc-ping-interval"`
|
||||||
PtyUser string `yaml:"pty-user"`
|
PtyUser string `yaml:"pty-user"`
|
||||||
PtyShell string `yaml:"pty-shell"`
|
PtyShell string `yaml:"pty-shell"`
|
||||||
XtermHtmlFile string `yaml:"xterm-html-file"`
|
XtermHtmlFile string `yaml:"xterm-html-file"`
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ func server_main(ctl_addrs []string, rpc_addrs []string, rpx_addrs[] string, pxy
|
|||||||
|
|
||||||
config.CtlPrefix = cfg.CTL.Service.Prefix
|
config.CtlPrefix = cfg.CTL.Service.Prefix
|
||||||
config.RpcMaxConns = cfg.APP.MaxRpcConns
|
config.RpcMaxConns = cfg.APP.MaxRpcConns
|
||||||
|
config.RpcMinPingIntvl = cfg.APP.MinRpcPingIntvl
|
||||||
config.MaxPeers = cfg.APP.MaxPeers
|
config.MaxPeers = cfg.APP.MaxPeers
|
||||||
|
|
||||||
pty_user = cfg.APP.PtyUser
|
pty_user = cfg.APP.PtyUser
|
||||||
|
|||||||
10
server.go
10
server.go
@@ -23,6 +23,7 @@ import "unsafe"
|
|||||||
import "golang.org/x/net/websocket"
|
import "golang.org/x/net/websocket"
|
||||||
import "google.golang.org/grpc"
|
import "google.golang.org/grpc"
|
||||||
import "google.golang.org/grpc/credentials"
|
import "google.golang.org/grpc/credentials"
|
||||||
|
import "google.golang.org/grpc/keepalive"
|
||||||
import "google.golang.org/grpc/peer"
|
import "google.golang.org/grpc/peer"
|
||||||
import "google.golang.org/grpc/stats"
|
import "google.golang.org/grpc/stats"
|
||||||
import "github.com/prometheus/client_golang/prometheus"
|
import "github.com/prometheus/client_golang/prometheus"
|
||||||
@@ -61,6 +62,7 @@ type ServerConfig struct {
|
|||||||
RpcAddrs []string
|
RpcAddrs []string
|
||||||
RpcTls *tls.Config
|
RpcTls *tls.Config
|
||||||
RpcMaxConns int
|
RpcMaxConns int
|
||||||
|
RpcMinPingIntvl time.Duration
|
||||||
MaxPeers int
|
MaxPeers int
|
||||||
|
|
||||||
CtlAddrs []string
|
CtlAddrs []string
|
||||||
@@ -1729,6 +1731,14 @@ func NewServer(ctx context.Context, name string, logger Logger, cfg *ServerConfi
|
|||||||
s.wpx_addrs = list.New()
|
s.wpx_addrs = list.New()
|
||||||
|
|
||||||
opts = append(opts, grpc.StatsHandler(&ConnCatcher{server: &s}))
|
opts = append(opts, grpc.StatsHandler(&ConnCatcher{server: &s}))
|
||||||
|
if s.Cfg.RpcMinPingIntvl > 0 {
|
||||||
|
// https://pkg.go.dev/google.golang.org/grpc/keepalive
|
||||||
|
// grpc library default is 5 minutes if this option is not added.
|
||||||
|
opts = append(opts, grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{
|
||||||
|
MinTime: s.Cfg.RpcMinPingIntvl,
|
||||||
|
PermitWithoutStream: true,
|
||||||
|
}))
|
||||||
|
}
|
||||||
if s.Cfg.RpcTls != nil { opts = append(opts, grpc.Creds(credentials.NewTLS(s.Cfg.RpcTls))) }
|
if s.Cfg.RpcTls != nil { opts = append(opts, grpc.Creds(credentials.NewTLS(s.Cfg.RpcTls))) }
|
||||||
//opts = append(opts, grpc.UnaryInterceptor(unaryInterceptor))
|
//opts = append(opts, grpc.UnaryInterceptor(unaryInterceptor))
|
||||||
//opts = append(opts, grpc.StreamInterceptor(streamInterceptor))
|
//opts = append(opts, grpc.StreamInterceptor(streamInterceptor))
|
||||||
|
|||||||
Reference in New Issue
Block a user