diff --git a/main.go b/main.go index 3deca7e..ab3a0b8 100644 --- a/main.go +++ b/main.go @@ -29,7 +29,6 @@ const ( // max open file should at least be _MaxOpenfile = uint64(1024 * 1024 * 1024) _MaxBackendAddrCacheCount = 1024 * 1024 - _DefaultPort = 4043 ) var ( @@ -50,6 +49,7 @@ var ( ) var ( + _DefaultPort = 4043 _BackendDialTimeout = 5 _ConnReadTimeout = time.Second * 30 ) @@ -87,6 +87,11 @@ func main() { _ConnReadTimeout = time.Second * time.Duration(connReadTimeout) } + listenPort, err := strconv.Atoi(os.Getenv("LISTEN_PORT")) + if err == nil && listenPort > 0 && listenPort <= 65535 { + _DefaultPort = listenPort + } + pprofPort, err := strconv.Atoi(os.Getenv("PPROF_PORT")) if err == nil && pprofPort > 0 && pprofPort <= 65535 { go func() {