Skip to content

Commit 0358a1b

Browse files
authored
falling back to PORT env variable if HTTP_PORT is not set (#212)
1 parent b51b914 commit 0358a1b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/kit/config.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package kit
22

33
import (
4+
"os"
45
"runtime"
6+
"strconv"
57
"time"
68

79
"github.com/kelseyhightower/envconfig"
@@ -53,7 +55,12 @@ func loadConfig() Config {
5355
var cfg Config
5456
envconfig.MustProcess("", &cfg)
5557
if cfg.HTTPPort == 0 {
56-
cfg.HTTPPort = 8080
58+
var err error
59+
// fall back to PORT for GAE
60+
cfg.HTTPPort, err = strconv.Atoi(os.Getenv("PORT"))
61+
if err != nil {
62+
cfg.HTTPPort = 8080
63+
}
5764
}
5865
if cfg.RPCPort == 0 {
5966
cfg.RPCPort = 8081

0 commit comments

Comments
 (0)