Skip to content

Commit

Permalink
Merge pull request #12 from ckrissun/master
Browse files Browse the repository at this point in the history
configure listen port by environment variable
  • Loading branch information
tomasen committed Mar 30, 2016
2 parents e32c3c7 + 9142cb4 commit 8dfed10
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion main.go
Expand Up @@ -29,7 +29,6 @@ const (
// max open file should at least be
_MaxOpenfile = uint64(1024 * 1024 * 1024)
_MaxBackendAddrCacheCount = 1024 * 1024
_DefaultPort = 4043
)

var (
Expand All @@ -50,6 +49,7 @@ var (
)

var (
_DefaultPort = 4043
_BackendDialTimeout = 5
_ConnReadTimeout = time.Second * 30
)
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 8dfed10

Please sign in to comment.