From ad07dbffceca27c8ba1ecf0aba3e085ee4c0be5c Mon Sep 17 00:00:00 2001 From: Chuntao Lu Date: Fri, 1 Mar 2019 10:56:48 -0800 Subject: [PATCH] Bind on routable interface for all non-test env --- runtime/gateway.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/runtime/gateway.go b/runtime/gateway.go index 304974863..de24bbdac 100644 --- a/runtime/gateway.go +++ b/runtime/gateway.go @@ -61,8 +61,10 @@ var levelMap = map[string]zapcore.Level{ var defaultShutdownPollInterval = 500 * time.Millisecond var defaultCloseTimeout = 10000 * time.Millisecond -const localhost = "127.0.0.1" -const prod = "production" +const ( + localhost = "127.0.0.1" + testenv = "test" +) // Options configures the gateway type Options struct { @@ -213,7 +215,7 @@ func (gateway *Gateway) Bootstrap() error { gateway.Logger.Error("Error listening on port", zap.Error(err)) return errors.Wrap(err, "error listening on port") } - if gateway.localHTTPServer.RealIP != gateway.httpServer.RealIP && env == prod { + if gateway.localHTTPServer.RealIP != gateway.httpServer.RealIP && env != testenv { _, err := gateway.httpServer.JustListen() if err != nil { gateway.Logger.Error("Error listening on port", zap.Error(err)) @@ -236,7 +238,7 @@ func (gateway *Gateway) Bootstrap() error { // start TChannel server ip := localhost - if env == prod { + if env != testenv { tchannelIP, err := tchannel.ListenIP() if err != nil { return errors.Wrap(err, "error finding the best IP for tchannel")