From 2e1e2cb6b1b607ea0f8bab8d189de57d5f629bf4 Mon Sep 17 00:00:00 2001 From: tuand27613 Date: Mon, 21 Nov 2016 10:57:02 -0500 Subject: [PATCH 1/2] [FAB-923] Change orderer listener port standardize orderer listener port to 7050 side change: add etc/hyperledger/fabric to viper config paths patchset 2: fix up Dockerfile for image as well Change-Id: Ib389771e3a4d24ad0f995239c0b98b71b6a7a3bd Signed-off-by: tuand27613 --- bddtests/docker-compose-orderer-base.yml | 1 - bddtests/steps/orderer_util.py | 2 +- images/orderer/Dockerfile.in | 2 +- orderer/config/config.go | 3 ++- orderer/kafka/config_test.go | 2 +- orderer/orderer.yaml | 2 +- orderer/sample_clients/bd_counter/main.go | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bddtests/docker-compose-orderer-base.yml b/bddtests/docker-compose-orderer-base.yml index f6607385887..40dba098738 100644 --- a/bddtests/docker-compose-orderer-base.yml +++ b/bddtests/docker-compose-orderer-base.yml @@ -6,7 +6,6 @@ ordererBase: - ORDERER_GENERAL_BATCHSIZE=10 - ORDERER_GENERAL_MAXWINDOWSIZE=1000 - ORDERER_GENERAL_LISTENADDRESS=0.0.0.0 - - ORDERER_GENERAL_LISTENPORT=5005 - ORDERER_RAMLEDGER_HISTORY_SIZE=100 working_dir: /opt/gopath/src/github.com/hyperledger/fabric/orderer command: orderer diff --git a/bddtests/steps/orderer_util.py b/bddtests/steps/orderer_util.py index 1f36c18bee0..55a2289f71a 100644 --- a/bddtests/steps/orderer_util.py +++ b/bddtests/steps/orderer_util.py @@ -237,6 +237,6 @@ def generateBroadcastMessages(numToGenerate = 1, timeToHoldOpen = 1): def getGRPCChannel(ipAddress): - channel = implementations.insecure_channel(ipAddress, 5005) + channel = implementations.insecure_channel(ipAddress, 7050) print("Returning GRPC for address: {0}".format(ipAddress)) return channel diff --git a/images/orderer/Dockerfile.in b/images/orderer/Dockerfile.in index f4e55e2eff9..68fd5d2061a 100644 --- a/images/orderer/Dockerfile.in +++ b/images/orderer/Dockerfile.in @@ -3,5 +3,5 @@ RUN mkdir -p /var/hyperledger/db /etc/hyperledger/fabric COPY payload/orderer /usr/local/bin COPY payload/orderer.yaml /etc/hyperledger/fabric WORKDIR /etc/hyperledger/fabric -EXPOSE 5151 +EXPOSE 7050 CMD orderer diff --git a/orderer/config/config.go b/orderer/config/config.go index 30d88021771..dbf40dc1642 100644 --- a/orderer/config/config.go +++ b/orderer/config/config.go @@ -104,7 +104,7 @@ var defaults = TopLevel{ QueueSize: 1000, MaxWindowSize: 1000, ListenAddress: "127.0.0.1", - ListenPort: 5151, + ListenPort: 7050, GenesisMethod: "static", Profile: Profile{ Enabled: false, @@ -203,6 +203,7 @@ func Load() *TopLevel { config.AddConfigPath("../../.") config.AddConfigPath("../orderer/") config.AddConfigPath("../../orderer/") + config.AddConfigPath("/etc/hyperledger/fabric/") // Path to look for the config file in based on GOPATH gopath := os.Getenv("GOPATH") for _, p := range filepath.SplitList(gopath) { diff --git a/orderer/kafka/config_test.go b/orderer/kafka/config_test.go index 1432e466fb1..13adb98cac2 100644 --- a/orderer/kafka/config_test.go +++ b/orderer/kafka/config_test.go @@ -44,7 +44,7 @@ var testConf = &config.TopLevel{ QueueSize: 100, MaxWindowSize: 100, ListenAddress: "127.0.0.1", - ListenPort: 5151, + ListenPort: 7050, }, Kafka: config.Kafka{ Brokers: []string{"127.0.0.1:9092"}, diff --git a/orderer/orderer.yaml b/orderer/orderer.yaml index a756eee1bff..4def28673f1 100644 --- a/orderer/orderer.yaml +++ b/orderer/orderer.yaml @@ -35,7 +35,7 @@ General: ListenAddress: 127.0.0.1 # Listen port: The port on which to bind to listen - ListenPort: 5151 + ListenPort: 7050 # Genesis method: The method by which to retrieve/generate the genesis block GenesisMethod: static diff --git a/orderer/sample_clients/bd_counter/main.go b/orderer/sample_clients/bd_counter/main.go index 4b7c2c354ad..444c8c4bf21 100644 --- a/orderer/sample_clients/bd_counter/main.go +++ b/orderer/sample_clients/bd_counter/main.go @@ -54,7 +54,7 @@ func main() { flag.StringVar(&client.config.rpc, "rpc", "broadcast", "The RPC that this client is requesting.") flag.StringVar(&client.config.server, "server", - "127.0.0.1:5151", "The RPC server to connect to.") + "127.0.0.1:7050", "The RPC server to connect to.") flag.IntVar(&client.config.count, "count", 100, "When in broadcast mode, how many messages to send.") flag.StringVar(&loglevel, "loglevel", "info", From b0e902ea482a5dd4f5a82b8051052c2915811e59 Mon Sep 17 00:00:00 2001 From: tuand27613 Date: Mon, 21 Nov 2016 14:35:16 -0500 Subject: [PATCH 2/2] [FAB-1174] set orderer config path via env var use ORDERER_CONFIG_PATH env var to set path to orderer.yaml Change-Id: I5b179352d5fec1ff7331bfee20af71f92bc571e7 Signed-off-by: tuand27613 --- images/orderer/Dockerfile.in | 4 ++-- orderer/config/config.go | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/images/orderer/Dockerfile.in b/images/orderer/Dockerfile.in index 68fd5d2061a..3888300683d 100644 --- a/images/orderer/Dockerfile.in +++ b/images/orderer/Dockerfile.in @@ -1,7 +1,7 @@ FROM hyperledger/fabric-baseimage:_BASE_TAG_ +ENV ORDERER_CFG_PATH /etc/hyperledger/fabric RUN mkdir -p /var/hyperledger/db /etc/hyperledger/fabric COPY payload/orderer /usr/local/bin -COPY payload/orderer.yaml /etc/hyperledger/fabric -WORKDIR /etc/hyperledger/fabric +COPY payload/orderer.yaml $ORDERER_CFG_PATH EXPOSE 7050 CMD orderer diff --git a/orderer/config/config.go b/orderer/config/config.go index dbf40dc1642..251029bc10f 100644 --- a/orderer/config/config.go +++ b/orderer/config/config.go @@ -192,25 +192,30 @@ func (c *TopLevel) completeInitialization() { func Load() *TopLevel { config := viper.New() + config.SetConfigName("orderer") + alternativeCfgPath := os.Getenv("ORDERER_CFG_PATH") + if alternativeCfgPath != "" { + logger.Infof("User defined config file path: %s", alternativeCfgPath) + config.AddConfigPath(alternativeCfgPath) // Path to look for the config file in + } else { + config.AddConfigPath("./") + config.AddConfigPath("../../.") + config.AddConfigPath("../orderer/") + config.AddConfigPath("../../orderer/") + // Path to look for the config file in based on GOPATH + gopath := os.Getenv("GOPATH") + for _, p := range filepath.SplitList(gopath) { + ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/") + config.AddConfigPath(ordererPath) + } + } + // for environment variables config.SetEnvPrefix(Prefix) config.AutomaticEnv() replacer := strings.NewReplacer(".", "_") config.SetEnvKeyReplacer(replacer) - config.SetConfigName("orderer") - config.AddConfigPath("./") - config.AddConfigPath("../../.") - config.AddConfigPath("../orderer/") - config.AddConfigPath("../../orderer/") - config.AddConfigPath("/etc/hyperledger/fabric/") - // Path to look for the config file in based on GOPATH - gopath := os.Getenv("GOPATH") - for _, p := range filepath.SplitList(gopath) { - ordererPath := filepath.Join(p, "src/github.com/hyperledger/fabric/orderer/") - config.AddConfigPath(ordererPath) - } - err := config.ReadInConfig() if err != nil { panic(fmt.Errorf("Error reading %s plugin config: %s", Prefix, err))