diff --git a/cmd/config_parser.go b/cmd/config_parser.go index 7314e190..70d441cc 100644 --- a/cmd/config_parser.go +++ b/cmd/config_parser.go @@ -125,7 +125,7 @@ type ServerConfig struct { ReuseAddress bool ReusePort bool LoadBalancer gnet.LoadBalancing - TickInterval int + TickInterval time.Duration ReadBufferCap int WriteBufferCap int SocketRecvBuffer int @@ -165,7 +165,7 @@ func serverConfig() *ServerConfig { SoftLimit: uint64(konfig.Int64("server.softLimit")), HardLimit: uint64(konfig.Int64("server.hardLimit")), EnableTicker: konfig.Bool("server.enableTicker"), - TickInterval: konfig.Int("server.tickInterval"), + TickInterval: konfig.Duration("server.tickInterval"), MultiCore: konfig.Bool("server.multiCore"), LockOSThread: konfig.Bool("server.lockOSThread"), LoadBalancer: getLoadBalancer(konfig.String("server.loadBalancer")), diff --git a/gatewayd.yaml b/gatewayd.yaml index 8782bdaa..f4cbab0d 100644 --- a/gatewayd.yaml +++ b/gatewayd.yaml @@ -48,7 +48,7 @@ server: proxy: proxy enableTicker: False - tickInterval: 5 # seconds + tickInterval: 5s # seconds multiCore: True lockOSThread: False loadBalancer: roundrobin @@ -58,7 +58,7 @@ server: socketSendBuffer: 4096 reuseAddress: True reusePort: True - tcpKeepAlive: 3 # seconds + tcpKeepAlive: 3s # seconds tcpNoDelay: True incomingTrafficHandler: "null" diff --git a/network/pool.go b/network/pool.go index eab96b32..70e129cc 100644 --- a/network/pool.go +++ b/network/pool.go @@ -138,7 +138,7 @@ func NewPool( } // Verify that the pool is properly populated - logger.Debug().Msgf("There are %d clients in the pool", len(pool.ClientIDs())) + logger.Info().Msgf("There are %d clients in the pool", len(pool.ClientIDs())) if len(pool.ClientIDs()) != poolSize { logger.Error().Msg( "The pool size is incorrect, either because " + diff --git a/network/server.go b/network/server.go index 68549e4c..3dd26767 100644 --- a/network/server.go +++ b/network/server.go @@ -15,7 +15,7 @@ const ( Running Status = "running" Stopped Status = "stopped" - DefaultTickInterval = 5 + DefaultTickInterval = 5 * time.Second DefaultPoolSize = 10 DefaultBufferSize = 4096 ) @@ -33,7 +33,7 @@ type Server struct { SoftLimit uint64 HardLimit uint64 Status Status - TickInterval int + TickInterval time.Duration } func (s *Server) OnBoot(engine gnet.Engine) gnet.Action { @@ -48,6 +48,8 @@ func (s *Server) OnBoot(engine gnet.Engine) gnet.Action { s.hooksConfig.RunHooks(OnBooted, s, engine) + s.logger.Debug().Msg("GatewayD booted") + return gnet.None } @@ -123,7 +125,7 @@ func (s *Server) OnTick() (time.Duration, gnet.Action) { s.logger.Debug().Msg("GatewayD is ticking...") s.logger.Info().Msgf("Active connections: %d", s.engine.CountConnections()) s.hooksConfig.RunHooks(OnTick, s) - return time.Duration(s.TickInterval * int(time.Second)), gnet.None + return s.TickInterval, gnet.None } func (s *Server) Run() error { @@ -160,7 +162,7 @@ func (s *Server) IsRunning() bool { func NewServer( network, address string, softLimit, hardLimit uint64, - tickInterval int, + tickInterval time.Duration, options []gnet.Option, onIncomingTraffic, onOutgoingTraffic Traffic, proxy Proxy, @@ -211,7 +213,7 @@ func NewServer( } if tickInterval == 0 { - server.TickInterval = int(DefaultTickInterval) + server.TickInterval = DefaultTickInterval logger.Debug().Msgf("Tick interval is not set, using the default value") } else { server.TickInterval = tickInterval